Skip to content

Instantly share code, notes, and snippets.

@SaitoWu
Created October 8, 2012 17:31
Show Gist options
  • Save SaitoWu/3853774 to your computer and use it in GitHub Desktop.
Save SaitoWu/3853774 to your computer and use it in GitHub Desktop.
grit patch apply
require'grit'
repo = Grit::Repo.new(".") #=> #<Grit::Repo "/Users/saito/hanwen/.git">
# check_applies => 0(can apply) or 1(can not)
repo.git.check_applies("master", "new") #=> 0
patch = repo.git.get_patch("new") #=> raw_patch
# apply_patch => tree_sha
repo.git.apply_patch("master", patch) #=> "c9a4861d9b3229974a0b1b05b87583ab3a887629"
# commit => commit_sha
# commit_message, array_of_commit, actor, tree_sha, head
repo.index.commit('message', [repo.commits.first], nil, nil, 'master') #=> "877166a550805fe2ad670399a5fb84a71b643998"
require'grit'
repo = Grit::Repo.new(".") #=> #<Grit::Repo "/Users/saito/hanwen/.git">
# check_applies => 0(can apply) or 1(can not)
repo.git.check_applies("master", "new") #=> 0
repo.git.native(:merge, {:no_ff => true}, "master", "new") #=> "Merge made by the 'recursive' strategy.\n readme.md | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n"
@vsizov
Copy link

vsizov commented Oct 11, 2012

apply_patch.rb - doesn't work

@vsizov
Copy link

vsizov commented Oct 11, 2012

i've tested

@vsizov
Copy link

vsizov commented Oct 11, 2012

Also i can't find any way to create branch and create commit i Grit.
File merge_branch.rb - will help us create merge request. But can't help to create webeditor.

@SaitoWu
Copy link
Author

SaitoWu commented Oct 13, 2012

@vsizov I've tested without Gitlab, just run code in irb.

But, when i run Gitlab with this code which will not work. I think its a permission problem with unix.

Try to figure out.

@SaitoWu
Copy link
Author

SaitoWu commented Oct 14, 2012

@vsizov Grit native merge must run in a work tree. .. still need a satellite repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment