Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added git/svn tasks

  • Loading branch information...
commit 7898aa591684d6db56878323438e023ace77b433 1 parent f081d1f
Rodrigo Urubatan Ferreira Jardim urubatan authored
Showing with 67 additions and 0 deletions.
  1. +28 −0 git/publish.sake
  2. +39 −0 git/rebase.sake
28 git/publish.sake
View
@@ -0,0 +1,28 @@
+namespace :git do
+ desc "Push all changes to the SVN repository"
+ task :publish do
+ branch = `git branch | grep "*"`.strip[2..-1]
+ if branch != "master"
+ `git diff-files --quiet`
+ if $?.exitstatus == 1
+ puts "You have outstanding changes. Please commit them first."
+ exit 1
+ end
+
+ puts "* Merging topic '#{branch}' back into master..."
+ `git checkout master`
+ sh "git merge #{branch}"
+ switch = true
+ else
+ switch = false
+ end
+
+ puts "* Pushing changes..."
+ sh "git svn dcommit"
+
+ if switch
+ puts "* Switching back to #{branch}..."
+ `git checkout #{branch}`
+ end
+ end
+end
39 git/rebase.sake
View
@@ -0,0 +1,39 @@
+namespace :git do
+ desc "Pull new commits from the SVN repository"
+ task :rebase do
+ `git diff-files --quiet`
+ if $?.exitstatus == 1
+ stash = true
+ clear = `git stash list`.scan("\n").size == 0
+ puts "* Saving changes..."
+ `git stash save`
+ else
+ stash = false
+ end
+
+ branch = `git branch | grep "*"`.strip[2..-1]
+ if branch != "master"
+ switch = true
+ `git checkout master`
+ puts "* Switching back to master..."
+ else
+ switch = false
+ end
+
+ puts "* Pulling in new commits..."
+ sh "git svn fetch"
+ sh "git rebase trunk"
+
+ if switch
+ puts "* Porting changes into #{branch}..."
+ `git checkout #{branch}`
+ sh "git rebase master"
+ end
+
+ if stash
+ puts "* Applying changes..."
+ sh "git stash apply"
+ `git stash clear` if clear
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.