Skip to content

Commit 0d397d8

Browse files
author
Koji Ishii
committed
hg-functions supports git
1 parent 90fd4ce commit 0d397d8

1 file changed

Lines changed: 39 additions & 18 deletions

File tree

bin/hg-functions

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,39 @@
1-
# You always want to do rebase pulls.
2-
alias pull='hg pull --rebase'
3-
4-
# You always want to pull before pushing, to avoid spurious collisions.
5-
alias push='pull && hg push'
6-
7-
# Commits, and prepends the current directory name to the commit message.
8-
# Just pass it the commit message as an argument.
9-
function save {
10-
local msg=$1; shift
11-
hg commit -m "[${PWD##*/}] ${msg}" $*
12-
}
13-
14-
# Regens, commits, and pulls/pushes, all in one package.
15-
# Pass it the commit message as an argument.
16-
function rcommit {
17-
regenerate && save "${1}" . && push
18-
}
1+
if [ -f ${BASH_SOURCE%/*}/../.git/config ]; then
2+
3+
# You always want to do rebase pulls.
4+
alias pull='git pull --rebase'
5+
6+
# You always want to pull before pushing, to avoid spurious collisions.
7+
alias push='pull && git push'
8+
9+
# Commits, and prepends the current directory name to the commit message.
10+
# Just pass it the commit message as an argument.
11+
function save {
12+
local msg=$1; shift
13+
git commit -a -m "[${PWD##*/}] ${msg}" $*
14+
}
15+
16+
elif [ -f ${BASH_SOURCE%/*}/../.hg/hgrc ]; then
17+
18+
# You always want to do rebase pulls.
19+
alias pull='hg pull --rebase'
20+
21+
# You always want to pull before pushing, to avoid spurious collisions.
22+
alias push='pull && hg push'
23+
24+
# Commits, and prepends the current directory name to the commit message.
25+
# Just pass it the commit message as an argument.
26+
function save {
27+
local msg=$1; shift
28+
hg commit -m "[${PWD##*/}] ${msg}" $*
29+
}
30+
31+
# Regens, commits, and pulls/pushes, all in one package.
32+
# Pass it the commit message as an argument.
33+
function rcommit {
34+
regenerate && save "${1}" . && push
35+
}
36+
else
37+
echo "Neither .git nor .hg found"
38+
exit 1
39+
fi

0 commit comments

Comments
 (0)