[DRE-commits] [gem2deb] 01/02: rake snapshot:install: restore master branch on failure

Antonio Terceiro terceiro at moszumanska.debian.org
Sun May 17 13:09:16 UTC 2015


This is an automated email from the git hooks/post-receive script.

terceiro pushed a commit to branch master
in repository gem2deb.

commit 0b5f31c1730a612de2c812ab5eefcfc37c216efc
Author: Antonio Terceiro <terceiro at debian.org>
Date:   Sun May 17 10:05:43 2015 -0300

    rake snapshot:install: restore master branch on failure
---
 Rakefile | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/Rakefile b/Rakefile
index 9016e1e..8aa1160 100644
--- a/Rakefile
+++ b/Rakefile
@@ -38,24 +38,24 @@ end
 desc "Builds a git snapshot package"
 task :snapshot => ['snapshot:build', 'snapshot:clean']
 
-task 'snapshot:build' do
+task 'snapshot:install' do
+  if !system('git diff-index --quiet HEAD')
+    fail "Can't build package; you have uncommitted changes"
+  end
+
   date = `date --iso=seconds |sed 's/+.*//' |sed 's/[-T:]//g'`.chomp
+  branch = `git symbolic-ref --short HEAD`.strip
+  newbranch = 'snapshot-' + date
+
+  sh 'git checkout -b ' + newbranch
   sh "sed -i '1 s/)/~git#{date})/' debian/changelog"
   sh 'git commit -a -m snapshot-' + date
-  sh 'git branch snapshot-' + date
-  sh 'DEB_BUILD_OPTIONS=nocheck gbp buildpackage --git-ignore-branch -us -uc'
-end
-
-desc 'Build and install a git snapshot'
-task 'snapshot:install' do
-  Rake::Task['snapshot:build'].invoke
-  sh 'sudo debi'
-  Rake::Task['snapshot:clean'].invoke
-end
-
-task 'snapshot:clean' do
-  sh 'git reset --hard HEAD^'
-  sh 'fakeroot debian/rules clean'
+  begin
+    sh 'DEB_BUILD_OPTIONS=nocheck gbp buildpackage --git-ignore-branch -us -uc'
+    sh 'sudo debi'
+  ensure
+    sh 'git checkout ' + branch
+  end
 end
 
 desc "Checks for inconsistencies between version numbers in the code and in debian/changelog"

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/gem2deb.git



More information about the Pkg-ruby-extras-commits mailing list