Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

coloring

  • Loading branch information...
commit 42752eb1fa65f27da99cd60a613db1db985a9821 1 parent c21d177
@orefalo authored
View
1  README.md
@@ -422,6 +422,7 @@ Distributed under the GNU General Public License, version 2.0.
## FIXED / DONE
+* Many commands are now colorized
* Added tips of the day
* fix issue with --set-upstream being deprecated
* fix warning when running: g track <remote/branch>
View
4 cmds/g2-abort.sh
@@ -2,4 +2,6 @@
#
# Aborts a merge or rebase
-[[ ! $("$GIT_EXE" rev-parse --git-dir 2> /dev/null) ]] && echo "fatal: Not a Git Repository" || ("$GIT_EXE" merge --abort 2> /dev/null || "$GIT_EXE" rebase --abort 2> /dev/null)
+source "$G2_HOME/cmds/color.sh"
+
+[[ ! $("$GIT_EXE" rev-parse --git-dir 2> /dev/null) ]] && echo_fatal "fatal: Not a Git Repository" || ("$GIT_EXE" merge --abort 2> /dev/null || "$GIT_EXE" rebase --abort 2> /dev/null)
View
5 cmds/g2-ci.sh
@@ -1,6 +1,7 @@
#!/bin/bash
#
#
+source "$G2_HOME/cmds/color.sh"
-[[ $("$GIT_EXE" g2iswip) = "true" ]] && echo "fatal: WIP detected, please <unwip> first." && exit 1
-[[ $("$GIT_EXE" diff --cached --numstat | wc -l) -eq 0 ]] && echo "fatal: No files to commit, please <freeze> changes first." || "$GIT_EXE" commit -u "$@"
+[[ $("$GIT_EXE" g2iswip) = "true" ]] && echo_fatal "fatal: WIP detected, please <unwip> first." && exit 1
+[[ $("$GIT_EXE" diff --cached --numstat | wc -l) -eq 0 ]] && echo_fatal "fatal: No files to commit, please <freeze> changes first." || "$GIT_EXE" commit -u "$@"
View
10 cmds/g2-co.sh
@@ -1,9 +1,11 @@
#!/bin/bash
#
+source "$G2_HOME/cmds/color.sh"
+
hasChanges() {
- [[ $("$GIT_EXE" diff --cached --numstat | wc -l) -ne 0 ]] && echo "fatal: staged changed detected, please commit <ci> or <wip> them." && exit 1
- [[ $("$GIT_EXE" diff --numstat | wc -l) -ne 0 ]] && echo "fatal: some files were changed in this branch, either commit <ci>, <wip> or <panic>." && exit 1
+ [[ $("$GIT_EXE" diff --cached --numstat | wc -l) -ne 0 ]] && echo_fatal "fatal: staged changed detected, please commit <ci> or <wip> them." && exit 1
+ [[ $("$GIT_EXE" diff --numstat | wc -l) -ne 0 ]] && echo_fatal "fatal: some files were changed in this branch, either commit <ci>, <wip> or <panic>." && exit 1
}
isBranch=$("$GIT_EXE" branch -a | grep -c "$1")
@@ -15,6 +17,6 @@ isBranch=$("$GIT_EXE" branch -a | grep -c "$1")
exit $?;
}
-echo "There is no branch called '$1', you may want to run 'g fetch <remote_name>' to refresh from the server"
-echo "If you are trying to revert a file, consider 'g undo <file>'"
+echo_info "There is no branch called '$1', you may want to run 'g fetch <remote_name>' to refresh from the server"
+echo_info "If you are trying to revert a file, consider 'g undo <file>'"
View
6 cmds/g2-continue.sh
@@ -4,13 +4,15 @@
# Unlike git, it detects what needs to be resumed: rebase or merge
# and smartly run the right command
+source "$G2_HOME/cmds/color.sh"
+
state=$("$GIT_EXE" g2brstatus)
[[ $state = "rebase" ]] && {
action="--continue"
if git diff-index --quiet HEAD --; then
- echo "The last commit brings no significant changes -- skipping"
+ echo_info "The last commit brings no significant changes -- skipping"
action="--skip"
fi
@@ -21,5 +23,5 @@ state=$("$GIT_EXE" g2brstatus)
[[ $state = "merge" ]] && {
# Count the number of unmerged files
count=$("$GIT_EXE" ls-files --unmerged | wc -l)
- [[ $count -ne 0 ]] && echo "I am afraid you still have unmerged files, please run <g mt> to resolv conflicts" ||"$GIT_EXE" commit
+ [[ $count -ne 0 ]] && echo_fatal "I am afraid you still have unmerged files, please run <g mt> to resolve conflicts" ||"$GIT_EXE" commit
}
View
4 cmds/g2-cp.sh
@@ -2,5 +2,7 @@
#
# Cherry picking, but forbids anything on top of wip commit
-[[ $("$GIT_EXE" g2iswip) = "true" ]] && echo "fatal: Cherry Picking on a WIP commit is forbiden, please <unwip> and commit <ci>" && exit 1
+source "$G2_HOME/cmds/color.sh"
+
+[[ $("$GIT_EXE" g2iswip) = "true" ]] && echo_fatal "fatal: Cherry Picking on a WIP commit is forbiden, please <unwip> and commit <ci>" && exit 1
"$GIT_EXE" cherry-pick "$@"
View
4 cmds/g2-g2add.sh
@@ -1,4 +1,4 @@
#!/bin/bash
#
-
-echo "You don't <add> with G2, you <freeze> and <unfreeze>"
+source "$G2_HOME/cmds/color.sh"
+echo_fatal "Don't use <add> with G2, <freeze> and <unfreeze> are powerfull commands"
View
5 cmds/g2-g2am.sh
@@ -1,8 +1,11 @@
#!/bin/bash
#
+source "$G2_HOME/cmds/color.sh"
+
+
error() {
- echo $1
+ echo_fatal $1
exit 1
}
View
4 cmds/g2-g2brstatus.sh
@@ -2,9 +2,11 @@
#
# Internal command that return "rebase", "merge" or "false"
+source "$G2_HOME/cmds/color.sh"
+
GDIR=$("$GIT_EXE" rev-parse --git-dir 2> /dev/null)
-[[ ! $GDIR ]] && echo "fatal: Not a Git Repository" && exit 1
+[[ ! $GDIR ]] && echo_fatal "fatal: Not a Git Repository" && exit 1
[[ -d "$GDIR/rebase-merge" || -d "$GDIR/rebase-apply" ]] && echo "rebase" && exit 0
[[ -f "$GDIR/MERGE_HEAD" ]] && echo "merge" && exit 0
echo "false"
View
4 cmds/g2-g2help.sh
@@ -1,7 +1,9 @@
#!/bin/bash
#
-echo "You can find all necessary help at http://orefalo.github.com/g2 & http://www.github.com/orefalo/g2"
+source "$G2_HOME/cmds/color.sh"
+
+echo -e "You can find all necessary help at ${boldon}http://orefalo.github.com/g2${boldoff} & ${boldon}http://www.github.com/orefalo/g2${reset}"
if [ $(uname -s) = "Darwin" ]; then
open "http://orefalo.github.com/g2"
View
2  cmds/g2-panic.sh
@@ -1,7 +1,7 @@
#!/bin/bash
#
-read -p "Remove all un-tracked files and checkout HEAD, are you sure (y/n)? " -n 1 -r
+read -p "This action will discard all work in progress and checkout HEAD, are you sure (y/n)? " -n 1 -r
[[ $REPLY == [yY]* ]] && {
echo
"$GIT_EXE" abort
View
4 cmds/g2-rb.sh
@@ -1,6 +1,8 @@
#!/bin/bash
#
+source "$G2_HOME/cmds/color.sh"
+
# substitute "upstream" with real upstream name
declare -a v=("$@")
declare i=0
@@ -8,7 +10,7 @@ for a in "${v[@]}"
do
[[ "$a" = "upstream" ]] && {
remote=$("$GIT_EXE" g2getremote)
- [[ -z $remote ]] && echo "fatal: upstream not found, please setup tracking for this branch, ie. <g track remote/branch>" && exit 1
+ [[ -z $remote ]] && echo_fatal "fatal: upstream not found, please setup tracking for this branch, ie. <g track remote/branch>" && exit 1
set -- "${@:1:$i}" "origin/master" "${@:($i+2)}";
} && break
let i++
View
8 cmds/g2-undo.sh
@@ -2,9 +2,11 @@
#
# easy undo a file, a commit or a merge
+source "$G2_HOME/cmds/color.sh"
+
if [ $# -lt 1 ]
then
- echo "Usage : g undo <file|commit|merge> <?path>"
+ echo_info "Usage : g undo <file|commit|merge> <?path>"
exit
fi
@@ -16,12 +18,12 @@ case "$1" in
"commit")
#TODO: Validate local commits
- echo "Undoing last commit and reverting changes to the staging area."
+ echo_info "Undoing last commit and reverting changes to the staging area."
"$GIT_EXE" reset --soft HEAD^
;;
"merge")
#TODO: Validate local commits
- echo "Reverting back prior to the last merge."
+ echo_info "Reverting back prior to the last merge."
"$GIT_EXE" reset --hard ORIG_HEAD
;;
*)
View
4 cmds/g2-unfreeze.sh
@@ -1,7 +1,9 @@
#!/bin/bash
#
-([[ -z "$@" ]] && ("$GIT_EXE" reset -q HEAD > /dev/null || echo "fatal: first commit must be unfrozen file by file.") || ("$GIT_EXE" reset -q HEAD -- $@ > /dev/null || "$GIT_EXE" rm -q --cached $@))
+source "$G2_HOME/cmds/color.sh"
+
+([[ -z "$@" ]] && ("$GIT_EXE" reset -q HEAD > /dev/null || echo_fatal "fatal: first commit must be unfrozen file by file.") || ("$GIT_EXE" reset -q HEAD -- $@ > /dev/null || "$GIT_EXE" rm -q --cached $@))
"$GIT_EXE" status -s;
View
3  cmds/g2-unwip.sh
@@ -1,4 +1,5 @@
#!/bin/bash
#
+source "$G2_HOME/cmds/color.sh"
-[[ $("$GIT_EXE" g2iswip) = "false" ]] && echo "fatal: there is nothing to <unwip>..." || ("$GIT_EXE" log -n 1 | grep -q -c wip && "$GIT_EXE" reset HEAD~1)
+[[ $("$GIT_EXE" g2iswip) = "false" ]] && echo_fatal "fatal: there is nothing to <unwip>..." || ("$GIT_EXE" log -n 1 | grep -q -c wip && "$GIT_EXE" reset HEAD~1)
View
3  cmds/g2-wip.sh
@@ -1,8 +1,9 @@
#!/bin/bash
#
+source "$G2_HOME/cmds/color.sh"
if [[ $("$GIT_EXE" g2iswip) = "true" ]]; then
- echo "info: amending previous wip commit..."
+ echo_info "info: amending previous wip commit..."
"$GIT_EXE" g2am
else
"$GIT_EXE" freeze -m wip
Please sign in to comment.
Something went wrong with that request. Please try again.