Skip to content

Commit

Permalink
Merge pull request simonthum#4 from boombatower/commit-message
Browse files Browse the repository at this point in the history
Allow commit message to be overridden by git config.
  • Loading branch information
simonthum committed Jul 1, 2014
2 parents 53a057d + e9c5e7a commit 4a58e27
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ name and time by default.

## Options

There are two `git config`-based options for tailoring your sync:
There are three `git config`-based options for tailoring your sync:

branch.$branch_name.syncNewFiles (bool)

Expand All @@ -103,6 +103,11 @@ present. Normally you have to commit those yourself to prevent
accidential additions. git-sync will exit at stage 3 with an
explanation in that case.

branch.$branch_name.syncCommitMsg (string)

A string which will be used in place of the default commit message (as shown
below).

branch.$branch_name.autocommitscript (string)

A string which is being eval'ed by this script to perform an
Expand Down
15 changes: 12 additions & 3 deletions git-sync
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@
# succeed.

# command used to auto-commit file modifications
DEFAULT_AUTOCOMMIT_CMD="git add -u ; git commit -m \"changes from $(uname -n) on $(date)\";"
DEFAULT_AUTOCOMMIT_CMD="git add -u ; git commit -m \"%message\";"

# command used to auto-commit all changes
ALL_AUTOCOMMIT_CMD="git add -A ; git commit -m \"changes from $(uname -n) on $(date)\";"
ALL_AUTOCOMMIT_CMD="git add -A ; git commit -m \"%message\";"

# default commit message substituted into autocommit commands
DEFAULT_AUTOCOMMIT_MSG="changes from $(uname -n) on $(date)"


# AUTOCOMMIT_CMD="echo \"Please commit or stash pending changes\"; exit 1;"
Expand Down Expand Up @@ -263,7 +266,13 @@ if [ ! -z "$(local_changes)" ]; then
else
autocommit_cmd=${DEFAULT_AUTOCOMMIT_CMD}
fi


commit_msg="$(git config --get branch.$branch_name.syncCommitMsg)"
if [ "" == "$commit_msg" ]; then
commit_msg=${DEFAULT_AUTOCOMMIT_MSG}
fi
autocommit_cmd=$(echo "$autocommit_cmd" | sed "s/%message/$commit_msg/")

echo "git-sync: Committing local changes using ${autocommit_cmd}"
eval $autocommit_cmd

Expand Down

0 comments on commit 4a58e27

Please sign in to comment.