File tree 1 file changed +15
-10
lines changed
1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -23,23 +23,28 @@ function log() {
23
23
echo -e " [$$ : $( date " +%Y-%m-%d %H:%M:%S %Z" ) ] $1 " >> " $log_path "
24
24
}
25
25
26
+ # Run a given command. If it fails, notify Slack and exits abnormally.
27
+ function run() {
28
+ if ! " $@ " ; then
29
+ " ${this_repo} /bin/notify-slack-failed-gem-update.rb" " $log_path " >> " $log_path " 2>&1
30
+ log " Failed: $@ "
31
+ exit 1
32
+ fi
33
+ }
34
+
26
35
# Initialize working directory only if missing
27
36
if [ ! -d " $ruby_workdir " ]; then
28
37
git clone " file://${ruby_repo} " " $ruby_workdir "
29
38
fi
30
39
31
40
log " ### start ###"
32
41
33
- git -C " $ruby_workdir " fetch origin master >> " $log_path " 2>&1
34
- git -C " $ruby_workdir " reset --hard origin/master >> " $log_path " 2>&1
42
+ run git -C " $ruby_workdir " fetch origin master >> " $log_path " 2>&1
43
+ run git -C " $ruby_workdir " reset --hard origin/master >> " $log_path " 2>&1
35
44
36
- if ruby -C " $ruby_workdir " tool/sync_default_gems.rb " $gem_name " " $before ..$after " >> " $log_path " 2>&1 ; then
37
- # Pushing ruby_workdir to cgit to make sure all git hooks are performed on sync-ed commits.
38
- if ! SVN_ACCOUNT_NAME=git git -C " $ruby_workdir " push origin " HEAD:master" >> " $log_path " 2>&1 ; then
39
- log " Failed: git push"
40
- fi
41
- else
42
- " ${this_repo} /bin/notify-slack-failed-gem-update.rb" " $log_path " >> " $log_path " 2>&1
43
- fi
45
+ run ruby -C " $ruby_workdir " tool/sync_default_gems.rb " $gem_name " " $before ..$after " >> " $log_path " 2>&1
46
+
47
+ # Pushing ruby_workdir to cgit to make sure all git hooks are performed on sync-ed commits.
48
+ SVN_ACCOUNT_NAME=git run git -C " $ruby_workdir " push origin " HEAD:master" >> " $log_path " 2>&1
44
49
45
50
log " ### end ###\n"
You can’t perform that action at this time.
0 commit comments