Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ The project id is best placed within your project's git config:

``git config -f .git/config pivotal.project-id 88888``

If you project's access is setup to use HTTPS:
If your project's access is setup to use HTTPS:

``git config -f .git/config pivotal.use-ssl 1``

Expand All @@ -69,6 +69,10 @@ If your Pivotal Tracker user name is different than your git user name:

``git config --global pivotal.full-name 'Ben Lindsey'``

If you prefer to have story branches deleted after they are merged by `git-finish`:

``git config --global pivotal.delete-branch 1``

If you would like verbose logging turned on for git commands:

``git config --global pivotal.verbose 1``
Expand Down
10 changes: 9 additions & 1 deletion lib/git_pivotal_tracker/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ def run!
protected

def integration_branch
options[:integration_branch] || 'master'
current_branch_suffix || options[:integration_branch] || 'master'
end

def current_branch_suffix
if current_branch =~ /.*-\d+?-(.*)/ and @repository.branches.any? { |branch| branch.name == $1 }
$1
end
end

def current_branch
Expand Down Expand Up @@ -79,6 +85,7 @@ def parse_gitconfig
options[:full_name] = repository.config['pivotal.full-name'] || repository.config['user.name']
options[:verbose] = repository.config['pivotal.verbose']
options[:use_ssl] = repository.config['pivotal.use-ssl']
options[:delete_branch] = repository.config['pivotal.delete-branch']
end

def parse_argv(*args)
Expand All @@ -90,6 +97,7 @@ def parse_argv(*args)
opts.on("-n", "--full-name=", "Your Pivotal Tracker full name") { |n| options[:full_name] = n }


opts.on("-D", "--delete-branch", "Delete store branch after merging") { |d| options[:delete_branch] = d }
opts.on("-I", "--include-rejected", "Include rejected stories as well as unstarted ones") { |i| options[:include_rejected] = i }
opts.on("-O", "--only-mine", "Only include stories that are assigned to me") { |o| options[:only_mine] = o }
opts.on("-F", "--fast-forward", "Merge topic branch with fast forward") { |f| options[:fast_forward] = f }
Expand Down
6 changes: 6 additions & 0 deletions lib/git_pivotal_tracker/finish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def run!

puts "Marking Story #{story_id} as finished..."
if story.update(:current_state => finished_state)
delete_current_branch if options[:delete_branch]
puts "Success"
return 0
else
Expand All @@ -41,5 +42,10 @@ def run!
def finished_state
story.story_type == "chore" ? "accepted" : "finished"
end

def delete_current_branch
puts "Deleting #{current_branch}"
log repository.git.branch({:raise => true, :d => true}, current_branch)
end
end
end
9 changes: 9 additions & 0 deletions spec/git_pivotal_tracker/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
it "leaves only_mine nil" do
subject.options[:only_mine].should be_nil
end

it "leaves delete_branch nil" do
subject.options[:delete_branch].should be_nil
end
end

it "sets the api_token" do
Expand Down Expand Up @@ -91,6 +95,11 @@
GitPivotalTracker::Base.new("--verbose").options[:verbose].should be
GitPivotalTracker::Base.new("-V").options[:verbose].should be
end

it "sets delete_branch" do
GitPivotalTracker::Base.new("--delete-branch").options[:delete_branch].should be
GitPivotalTracker::Base.new("-D").options[:delete_branch].should be
end
end

describe "#parse_gitconfig" do
Expand Down
16 changes: 16 additions & 0 deletions spec/git_pivotal_tracker/finish_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
@repo.commits.first.parents.should have(2).items
@repo.heads.detect { |h| h.name == @current_head.name }.commit.sha.should == @sha
end

it "does not delete story branch" do
finish.run!.should == 0
@repo.git.branch.should match @new_branch
end

context "when I have rebase turned on" do
before do
Expand All @@ -80,5 +85,16 @@
@repo.heads.detect { |h| h.name == @current_head.name }.commit.sha.should == @sha
end
end

context "when I have delete branch turned on" do
before do
finish.options[:delete_branch] = 1
end

it "deletes the story branch after merging" do
finish.run!.should == 0
@repo.git.branch.should_not match @new_branch
end
end
end
end