Skip to content
Browse files

git.add specific files only - resolves problem where files from conta…

…minated working dir were added to ticgit branch
  • Loading branch information...
1 parent bc4e44f commit 129540bb0990f886ab309336642e1d79a11fd906 @jeffWelling committed May 26, 2011
Showing with 33 additions and 13 deletions.
  1. +1 −1 lib/ticgit-ng/base.rb
  2. +32 −12 lib/ticgit-ng/ticket.rb
View
2 lib/ticgit-ng/base.rb
@@ -332,7 +332,7 @@ def init_ticgitng_branch(ticgitng_branch = false)
new_file('.hold', 'hold')
unless ticgitng_branch
- git.add
+ git.add ".hold"
git.commit('creating the ticgit-ng branch')
end
end
View
44 lib/ticgit-ng/ticket.rb
@@ -84,19 +84,29 @@ def self.parse_ticket_name(name)
# write this ticket to the git database
def save_new
base.in_branch do |wd|
+ files=[]
+ t=nil
base.logger.info "saving #{ticket_name}"
Dir.mkdir(ticket_name)
Dir.chdir(ticket_name) do
base.new_file('TICKET_ID', ticket_name)
+ files << File.join( ticket_name, 'TICKET_ID' )
base.new_file('TICKET_TITLE', title)
- base.new_file('ASSIGNED_' + email, email)
- base.new_file('STATE_' + state, state)
+ files << File.join( ticket_name, 'TICKET_TITLE' )
+ base.new_file( (t='ASSIGNED_'+email) , email)
+ files << File.join( ticket_name, t )
+ base.new_file( (t='STATE_'+state) , state)
+ files << File.join( ticket_name, t )
base.new_file('TITLE', title)
+ files << File.join( ticket_name, 'TITLE' )
# add initial comment
#COMMENT_080315060503045__schacon_at_gmail
- base.new_file(comment_name(email), opts[:comment]) if opts[:comment]
+ if opts[:comment]
+ base.new_file(t=comment_name(email), opts[:comment])
+ files << File.join( ticket_name, t )
+ end
# add initial tags
if opts[:tags] && opts[:tags].size > 0
@@ -106,12 +116,15 @@ def save_new
tag_filename = 'TAG_' + Ticket.clean_string(tag)
if !File.exists?(tag_filename)
base.new_file(tag_filename, tag_filename)
+ files << File.join( ticket_name, tag_filename )
end
end
end
end
end
- base.git.add
+ files.each {|file|
+ base.git.add file
+ }
base.git.commit("added ticket #{ticket_name}")
end
# ticket_id
@@ -124,24 +137,26 @@ def self.clean_string(string)
def add_comment(comment)
return false if !comment
base.in_branch do |wd|
+ t=nil
Dir.chdir(ticket_name) do
- base.new_file(comment_name(email), comment)
+ base.new_file(t=comment_name(email), comment)
end
- base.git.add
+ base.git.add File.join(ticket_name, t)
base.git.commit("added comment to ticket #{ticket_name}")
end
end
def change_state(new_state)
return false if !new_state
return false if new_state == state
+ t=nil
base.in_branch do |wd|
Dir.chdir(ticket_name) do
- base.new_file('STATE_' + new_state, new_state)
+ base.new_file(t='STATE_' + new_state, new_state)
end
base.git.remove(File.join(ticket_name,'STATE_' + state))
- base.git.add
+ base.git.add File.join(ticket_name, t)
base.git.commit("added state (#{new_state}) to ticket #{ticket_name}")
end
end
@@ -152,11 +167,12 @@ def change_assigned(new_assigned)
return false if new_assigned == old_assigned
base.in_branch do |wd|
+ t=nil
Dir.chdir(ticket_name) do
- base.new_file('ASSIGNED_' + new_assigned, new_assigned)
+ base.new_file(t='ASSIGNED_' + new_assigned, new_assigned)
end
base.git.remove(File.join(ticket_name,'ASSIGNED_' + old_assigned))
- base.git.add
+ base.git.add File.join(ticket_name,t)
base.git.commit("assigned #{new_assigned} to ticket #{ticket_name}")
end
end
@@ -168,13 +184,14 @@ def change_points(new_points)
Dir.chdir(ticket_name) do
base.new_file('POINTS', new_points)
end
- base.git.add
+ base.git.add File.join(ticket_name, 'POINTS')
base.git.commit("set points to #{new_points} for ticket #{ticket_name}")
end
end
def add_tag(tag)
return false if !tag
+ files=[]
added = false
tags = tag.split(',').map { |t| t.strip }
base.in_branch do |wd|
@@ -184,13 +201,16 @@ def add_tag(tag)
tag_filename = 'TAG_' + Ticket.clean_string(add_tag)
if !File.exists?(tag_filename)
base.new_file(tag_filename, tag_filename)
+ files << File.join( ticket_name, tag_filename )
added = true
end
end
end
end
if added
- base.git.add
+ files.each {|file|
+ base.git.add file
+ }
base.git.commit("added tags (#{tag}) to ticket #{ticket_name}")
end
end

0 comments on commit 129540b

Please sign in to comment.
Something went wrong with that request. Please try again.