#!/usr/bin/env bash
# 快速 git add + commit + push
# 用法: g "fix: 提交说明"
set -e

msg="${1:-}"
if [[ -z "$msg" ]]; then
  echo "用法: g \"commit message\""
  echo "示例: g \"fix: 修复登录问题\""
  exit 1
fi

# 检查是否有改动
if [[ -z $(git status --porcelain) ]]; then
  echo "无文件改动，跳过提交"
  exit 0
fi

git add .
git commit -m "$msg"
git push
echo "✓ 已推送"
