Project

General

Profile

Revision 6d91f38e

Added by Julien Enselme almost 8 years ago

Test added for git where posing trouble

We must use to launch function in a subshell, other wise the whole
script exit with the instruction 'exit 1' or 'exit 0'.
We must use " around variable for test. Otherwise, we get a Unexpected
operator error.

View differences:

bin/scripts-utils.sh
79 79

  
80 80
work_tree_clean() {
81 81
    git_status_output=`git status --porcelain`
82
    if [ -z $git_status_output ] ; then
82
    if [ -z "$git_status_output" ] ; then
83 83
	exit 0
84 84
    else
85 85
	exit 1
......
89 89
mail_unclean_work_tree() {
90 90
    cd $dir_multi_assos
91 91
    git_status_output=`git status`
92
    echo $git_status_output | mail -s $1 $email_multi_assos
92
    echo "$git_status_output" | mail -s "$1" $email_multi_assos
93 93
}
94 94

  
95 95
commit_if_unclean() {
96
    if ! work_tree_clean ; then
96
    if ! `work_tree_clean` ; then
97 97
	commit_message="COMMIT OF UNCLEAN STUFF"
98
	commit -a -m $commit_message
98
	commit -a -m "$commit_message"
99 99
	mail_unclean_work_tree "[git] $commit_message"
100 100
    fi
101 101
}
102 102

  
103 103
commit() {
104 104
    # ARG: commit message
105
    if [ -z $1 ] ; then
105
    if [ -z "$1" ] ; then
106 106
	echo "Empty commit message. Nothing was commited."
107 107
	exit 2
108 108
    fi
109 109
    cd $dir_multi_assos
110
    git commit -a -m $1
110
    git commit -a -m "$1"
111 111
}

Also available in: Unified diff