File tree Expand file tree Collapse file tree 1 file changed +15
-10
lines changed
Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -23,23 +23,28 @@ function log() {
2323 echo -e " [$$ : $( date " +%Y-%m-%d %H:%M:%S %Z" ) ] $1 " >> " $log_path "
2424}
2525
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+
2635# Initialize working directory only if missing
2736if [ ! -d " $ruby_workdir " ]; then
2837 git clone " file://${ruby_repo} " " $ruby_workdir "
2938fi
3039
3140log " ### start ###"
3241
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
3544
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
4449
4550log " ### end ###\n"
You can’t perform that action at this time.
0 commit comments