From f064b77d2b971869327ec47cd8af3bb9d13e8886 Mon Sep 17 00:00:00 2001 From: TJ Biddle Date: Tue, 18 Sep 2012 19:26:48 -0700 Subject: [PATCH 01/19] ignore all gem files since I build in the directory a lot --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 911e38d6..ddc07ca5 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ coverage rdoc pkg - +*.gem From 92653eb2cc8b844f8d06973a1cb6417fbf95cc7f Mon Sep 17 00:00:00 2001 From: TJ Biddle Date: Tue, 18 Sep 2012 19:27:19 -0700 Subject: [PATCH 02/19] bump version # --- git.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git.gemspec b/git.gemspec index 00e2b9f3..ca7d9ced 100644 --- a/git.gemspec +++ b/git.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |s| s.name = %q{git} - s.version = "1.2.5" + s.version = "1.2.6" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Scott Chacon"] From a8de13e19446d708a2b71992310063ed5de93a52 Mon Sep 17 00:00:00 2001 From: TJ Biddle Date: Tue, 18 Sep 2012 19:27:43 -0700 Subject: [PATCH 03/19] allow merge to pass along arguments. in my case, --squash --- lib/git/base.rb | 4 ++-- lib/git/lib.rb | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/git/base.rb b/lib/git/base.rb index 5ad8906a..e123ae66 100644 --- a/lib/git/base.rb +++ b/lib/git/base.rb @@ -310,8 +310,8 @@ def push(remote = 'origin', branch = 'master', tags = false) # merges one or more branches into the current working branch # # you can specify more than one branch to merge by passing an array of branches - def merge(branch, message = 'merge') - self.lib.merge(branch, message) + def merge(branch, message = 'merge', arr = []) + self.lib.merge(branch, message, arr) end # iterates over the files which are unmerged diff --git a/lib/git/lib.rb b/lib/git/lib.rb index 52fb2e6c..eb977869 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -499,8 +499,7 @@ def checkout_file(version, file) command('checkout', arr_opts) end - def merge(branch, message = nil) - arr_opts = [] + def merge(branch, message = nil, arr_opts = []) arr_opts << '-m' << message if message arr_opts += [branch] command('merge', arr_opts) From a0afc0eb90dd0c00366a4b904025c6c4eb7a0cdc Mon Sep 17 00:00:00 2001 From: TJ Biddle Date: Thu, 20 Sep 2012 14:16:56 -0700 Subject: [PATCH 04/19] Patch version bump. Git pull is a fetch and merge, but it needs to merge the remote - otherwise there is nothing to merge --- git.gemspec | 2 +- lib/git/base.rb | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/git.gemspec b/git.gemspec index ca7d9ced..55279752 100644 --- a/git.gemspec +++ b/git.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |s| s.name = %q{git} - s.version = "1.2.6" + s.version = "1.2.7" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Scott Chacon"] diff --git a/lib/git/base.rb b/lib/git/base.rb index e123ae66..71a214ac 100644 --- a/lib/git/base.rb +++ b/lib/git/base.rb @@ -322,7 +322,10 @@ def each_conflict(&block) # :yields: file, your_version, their_version # fetches a branch from a remote and merges it into the current working branch def pull(remote = 'origin', branch = 'master', message = 'origin pull') fetch(remote) - merge(branch, message) + old_branch = self.lib.branch_current + if self.lib.branch_current != branch then checkout(branch) end + merge(remote, message) + if self.lib.branch_current != branch then checkout(old_branch) end end # returns an array of Git:Remote objects From f990f8b278af89b3b14bdd31ac17294f7cc7f83d Mon Sep 17 00:00:00 2001 From: TJ Biddle Date: Wed, 28 Nov 2012 18:36:12 -0800 Subject: [PATCH 05/19] edge case was causing an error where it would fail out when getting the commit message. --- lib/git/lib.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/git/lib.rb b/lib/git/lib.rb index eb977869..d217fb22 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -144,7 +144,9 @@ def process_commit_data(data, sha = nil, indent = 4) value = data.join(' ') if key == 'commit' sha = value - hsh_array << hsh if hsh + if hsh_array + hsh_array << hsh if hsh + end hsh = {'sha' => sha, 'message' => '', 'parent' => []} end if key == 'parent' From e8764c2d6ee9f6f00119ae5e0befa7880e1473ee Mon Sep 17 00:00:00 2001 From: TJ Biddle Date: Wed, 28 Nov 2012 18:36:28 -0800 Subject: [PATCH 06/19] Version bump to 1.2.6 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index c813fe11..7e099ec5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.2.5 +1.2.6 \ No newline at end of file From 1ad754ca2e36daa72a4a9bcd261925e5e63a9105 Mon Sep 17 00:00:00 2001 From: TJ Biddle Date: Wed, 28 Nov 2012 18:36:33 -0800 Subject: [PATCH 07/19] Version bump to 1.2.7 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 7e099ec5..a77d7d92 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.2.6 \ No newline at end of file +1.2.7 \ No newline at end of file From 3caaebbbf70038675b9d6cc60539e0d260e123b7 Mon Sep 17 00:00:00 2001 From: TJ Biddle Date: Wed, 28 Nov 2012 18:36:34 -0800 Subject: [PATCH 08/19] Version bump to 1.2.8 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index a77d7d92..5975b143 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.2.7 \ No newline at end of file +1.2.8 \ No newline at end of file From 56300bf5322b86c16572eac1130c9795e9c3ffdb Mon Sep 17 00:00:00 2001 From: TJ Biddle Date: Tue, 19 Mar 2013 11:59:58 -0700 Subject: [PATCH 09/19] No idea why I changed pull to merge this way, but the original was correct. --- lib/git/base.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/git/base.rb b/lib/git/base.rb index 71a214ac..e4e57d8d 100644 --- a/lib/git/base.rb +++ b/lib/git/base.rb @@ -322,10 +322,7 @@ def each_conflict(&block) # :yields: file, your_version, their_version # fetches a branch from a remote and merges it into the current working branch def pull(remote = 'origin', branch = 'master', message = 'origin pull') fetch(remote) - old_branch = self.lib.branch_current - if self.lib.branch_current != branch then checkout(branch) end merge(remote, message) - if self.lib.branch_current != branch then checkout(old_branch) end end # returns an array of Git:Remote objects From 129e798a8df367bd4ff08b47402feb2203d04d5d Mon Sep 17 00:00:00 2001 From: TJ Biddle Date: Tue, 19 Mar 2013 17:29:54 -0700 Subject: [PATCH 10/19] Updating pull method to do a normal git pull with it's remove and branch specified rather than do a fetch and merge. --- git.gemspec | 2 +- lib/git/base.rb | 5 ++--- lib/git/lib.rb | 4 ++++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/git.gemspec b/git.gemspec index 55279752..0f3ca76d 100644 --- a/git.gemspec +++ b/git.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |s| s.name = %q{git} - s.version = "1.2.7" + s.version = "1.2.9" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Scott Chacon"] diff --git a/lib/git/base.rb b/lib/git/base.rb index e4e57d8d..a095ff41 100644 --- a/lib/git/base.rb +++ b/lib/git/base.rb @@ -320,9 +320,8 @@ def each_conflict(&block) # :yields: file, your_version, their_version end # fetches a branch from a remote and merges it into the current working branch - def pull(remote = 'origin', branch = 'master', message = 'origin pull') - fetch(remote) - merge(remote, message) + def pull(remote = 'origin', branch = 'master') + self.lib.pull(remote, branch) end # returns an array of Git:Remote objects diff --git a/lib/git/lib.rb b/lib/git/lib.rb index d217fb22..cf05a00d 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -507,6 +507,10 @@ def merge(branch, message = nil, arr_opts = []) command('merge', arr_opts) end + def pull(remote, branch) + command('pull', [remote, branch]) + end + def unmerged unmerged = [] command_lines('diff', ["--cached"]).each do |line| From 67083e1eb06b35d081e2bcb30d2159f235adfede Mon Sep 17 00:00:00 2001 From: TJ Biddle Date: Tue, 19 Mar 2013 17:43:23 -0700 Subject: [PATCH 11/19] Adding git clean command. --- lib/git/base.rb | 5 +++++ lib/git/lib.rb | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/lib/git/base.rb b/lib/git/base.rb index a095ff41..0c5320cc 100644 --- a/lib/git/base.rb +++ b/lib/git/base.rb @@ -264,6 +264,11 @@ def reset_hard(commitish = nil, opts = {}) self.lib.reset(commitish, opts) end + def clean(opts = {}) + opts = { :force => true, :d => true }.merge(opts) + self.lib.clean(opts) + end + # commits all pending changes in the index file to the git repository # # options: diff --git a/lib/git/lib.rb b/lib/git/lib.rb index cf05a00d..e061ee30 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -431,6 +431,13 @@ def reset(commit, opts = {}) arr_opts << commit if commit command('reset', arr_opts) end + + def clean(opts = {}) + arr_opts = [] + arr_opts << '--force' if opts[:force] + arr_opts << '-d' if opts[:d] + command('clean', arr_opts) + end def apply(patch_file) arr_opts = [] From 26e62427a7c01784c4f21305b8b730cee711183f Mon Sep 17 00:00:00 2001 From: TJ Biddle Date: Thu, 28 Mar 2013 14:35:45 -0700 Subject: [PATCH 12/19] Updating the git pull command so that we can pass in by option the remote and branch, and it will default to whatever is the normal for the current branch. This way we can also pull in a single remote. --- lib/git/base.rb | 2 +- lib/git/lib.rb | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/git/base.rb b/lib/git/base.rb index 0c5320cc..2da0a8b8 100644 --- a/lib/git/base.rb +++ b/lib/git/base.rb @@ -325,7 +325,7 @@ def each_conflict(&block) # :yields: file, your_version, their_version end # fetches a branch from a remote and merges it into the current working branch - def pull(remote = 'origin', branch = 'master') + def pull(remote = nil, branch = nil) self.lib.pull(remote, branch) end diff --git a/lib/git/lib.rb b/lib/git/lib.rb index e061ee30..a76cea61 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -514,8 +514,11 @@ def merge(branch, message = nil, arr_opts = []) command('merge', arr_opts) end - def pull(remote, branch) - command('pull', [remote, branch]) + def pull(remote = nil, branch = nil) + opts = [] + opts << remote if remote + opts << branch if branch + command('pull', opts) end def unmerged From 4ee3e340a6c1aeae8ec4be04b7367b022e838aa5 Mon Sep 17 00:00:00 2001 From: TJ Biddle Date: Thu, 13 Jun 2013 13:50:14 -0400 Subject: [PATCH 13/19] Adding support for submodules. --- lib/git/base.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/git/base.rb b/lib/git/base.rb index 2da0a8b8..fb4014a9 100644 --- a/lib/git/base.rb +++ b/lib/git/base.rb @@ -24,9 +24,18 @@ def self.init(working_dir, opts = {}) :working_directory => working_dir, :repository => File.join(working_dir, '.git') }.merge(opts) - + FileUtils.mkdir_p(opts[:working_directory]) if opts[:working_directory] && !File.directory?(opts[:working_directory]) - + + # Submodules have a .git *file* not a .git folder. + # This file's contents point to the location of + # where the git refs are held (In the parent repo) + if File.file?('.git') + git_file = File.open('.git').read[8..-1].strip + opts[:repository] = git_file + opts[:index] = git_file + '/index' + end + # run git_init there Git::Lib.new(opts).init From ffe46da0092d44243b6dbdc0ac1a4a8e9a05834c Mon Sep 17 00:00:00 2001 From: TJ Biddle Date: Thu, 13 Jun 2013 13:50:38 -0400 Subject: [PATCH 14/19] version bump --- git.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git.gemspec b/git.gemspec index 0f3ca76d..650f9553 100644 --- a/git.gemspec +++ b/git.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |s| s.name = %q{git} - s.version = "1.2.9" + s.version = "1.2.11" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Scott Chacon"] From 97e40641c6a63d761fa9c57de3173088acfe6e92 Mon Sep 17 00:00:00 2001 From: TJ Biddle Date: Mon, 29 Jul 2013 18:56:20 -0700 Subject: [PATCH 15/19] Fixing issue where branches with forward slashes '/' were not being properly built. --- lib/git/branch.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/git/branch.rb b/lib/git/branch.rb index 15101b33..edfce5be 100644 --- a/lib/git/branch.rb +++ b/lib/git/branch.rb @@ -9,13 +9,13 @@ def initialize(base, name) @base = base @gcommit = nil @stashes = nil - + parts = name.split('/') - if parts[1] + if parts[0] == 'remotes' @remote = Git::Remote.new(@base, parts[0]) - @name = parts[1] + @name = parts[2..-1].join('/') else - @name = parts[0] + @name = name end end From b88e05e718fd39048274cf3c25b8ef52734b1a8f Mon Sep 17 00:00:00 2001 From: TJ Biddle Date: Mon, 29 Jul 2013 18:56:42 -0700 Subject: [PATCH 16/19] version bump --- git.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git.gemspec b/git.gemspec index 650f9553..ae764942 100644 --- a/git.gemspec +++ b/git.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |s| s.name = %q{git} - s.version = "1.2.11" + s.version = "1.2.12" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Scott Chacon"] From fc5e634dccd578a074edb6d0b44ad7c7e1080745 Mon Sep 17 00:00:00 2001 From: TJ Biddle Date: Mon, 29 Jul 2013 19:34:09 -0700 Subject: [PATCH 17/19] When checking out a branch it was actually adding the new_branch option as an argument. What would the argument be? We're already adding on the branch at the end - -b doesn't take an arugmeny... --- lib/git/lib.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/git/lib.rb b/lib/git/lib.rb index a76cea61..a29811d7 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -495,7 +495,7 @@ def branch_delete(branch) def checkout(branch, opts = {}) arr_opts = [] arr_opts << '-f' if opts[:force] - arr_opts << '-b' << opts[:new_branch] if opts[:new_branch] + arr_opts << '-b' if opts[:new_branch] arr_opts << branch command('checkout', arr_opts) From 13374a0536531d9f6c20441e50d7a99273145be7 Mon Sep 17 00:00:00 2001 From: TJ Biddle Date: Mon, 5 Aug 2013 13:08:29 -0700 Subject: [PATCH 18/19] Add git rebase command. --- git.gemspec | 2 +- lib/git/base.rb | 4 ++++ lib/git/branch.rb | 5 +++++ lib/git/lib.rb | 4 ++++ ruby-git.gemspec | 2 +- 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/git.gemspec b/git.gemspec index ae764942..68e0c5de 100644 --- a/git.gemspec +++ b/git.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |s| s.name = %q{git} - s.version = "1.2.12" + s.version = "1.2.13" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Scott Chacon"] diff --git a/lib/git/base.rb b/lib/git/base.rb index fb4014a9..34e62a21 100644 --- a/lib/git/base.rb +++ b/lib/git/base.rb @@ -328,6 +328,10 @@ def merge(branch, message = 'merge', arr = []) self.lib.merge(branch, message, arr) end + def rebase(branch) + self.lib.rebase(branch) + end + # iterates over the files which are unmerged def each_conflict(&block) # :yields: file, your_version, their_version self.lib.conflicts(&block) diff --git a/lib/git/branch.rb b/lib/git/branch.rb index edfce5be..a0b3bff0 100644 --- a/lib/git/branch.rb +++ b/lib/git/branch.rb @@ -77,6 +77,11 @@ def merge(branch = nil, message = nil) @base.merge(@name) end end + + def rebase(branch) + @base.rebase(branch) + end + def update_ref(commit) @base.lib.update_ref(@full, commit) diff --git a/lib/git/lib.rb b/lib/git/lib.rb index a29811d7..0d6c375f 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -514,6 +514,10 @@ def merge(branch, message = nil, arr_opts = []) command('merge', arr_opts) end + def rebase(branch) + command('rebase', [branch]) + end + def pull(remote = nil, branch = nil) opts = [] opts << remote if remote diff --git a/ruby-git.gemspec b/ruby-git.gemspec index d42ff3d9..3c9d683a 100644 --- a/ruby-git.gemspec +++ b/ruby-git.gemspec @@ -1,7 +1,7 @@ spec = Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = "git" - s.version = "1.1.1" + s.version = "1.1.13" s.author = "Scott Chacon" s.email = "schacon@gmail.com" s.homepage = "http://github.com/schacon/ruby-git/tree/master" From 5572a5a1ba8ad5d6aaa4c7581279b5047b296066 Mon Sep 17 00:00:00 2001 From: TJ Biddle Date: Tue, 19 Mar 2013 17:43:23 -0700 Subject: [PATCH 19/19] Adding git clean command. --- lib/git/base.rb | 5 +++++ lib/git/lib.rb | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/lib/git/base.rb b/lib/git/base.rb index 5ad8906a..c424f0f4 100644 --- a/lib/git/base.rb +++ b/lib/git/base.rb @@ -264,6 +264,11 @@ def reset_hard(commitish = nil, opts = {}) self.lib.reset(commitish, opts) end + def clean(opts = {}) + opts = { :force => true, :d => true }.merge(opts) + self.lib.clean(opts) + end + # commits all pending changes in the index file to the git repository # # options: diff --git a/lib/git/lib.rb b/lib/git/lib.rb index 52fb2e6c..79dcd525 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -429,6 +429,13 @@ def reset(commit, opts = {}) arr_opts << commit if commit command('reset', arr_opts) end + + def clean(opts = {}) + arr_opts = [] + arr_opts << '--force' if opts[:force] + arr_opts << '-d' if opts[:d] + command('clean', arr_opts) + end def apply(patch_file) arr_opts = []