Skip to content
This repository has been archived by the owner on Oct 27, 2019. It is now read-only.

Commit

Permalink
Commits are done with the corresponding author's name
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerian committed Oct 24, 2010
1 parent 777c1dd commit 4756d84
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion features/do_conversion.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ Scenario Outline: Do conversion
Scenarios: Origin has commit that arent on the destiny
| origin | name_origin | name_destiny | destiny |
| http://svn.github.com/Nerian/JPovray.git | origin | destiny | file:///tmp/Server_Repos/destiny |
| http://svn.github.com/Nerian/DPovray.git | origin | destiny | file:///tmp/Server_Repos/destiny |
#| http://svn.github.com/Nerian/DPovray.git | origin | destiny | file:///tmp/Server_Repos/destiny |

23 changes: 19 additions & 4 deletions lib/conversor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ class Conversor
def initialize(output=STDOUT, svn_address_origin, svn_address_destiny)
@output = output
@svn_origin_name = "origin"
@svn_destiny_name = "destiny"
@svn_destiny_name = "destiny"
@svn_address_origin = svn_address_origin
@svn_address_destiny = svn_address_destiny
@log_file_of_origin = "/tmp/log_file_of_origin"

checkout_origin_repo()
checkout_destiny_repo()
Expand Down Expand Up @@ -157,7 +158,9 @@ def check_if_this_is_a_phantom_commit()
def perform_conversion_operations(revision_number_that_we_want_to_copy_to_destiny)

# Checkout a temporal repo that will contain the changes –– revision – that we want to apply to destiny
checkout_origin_repo(revision_number_that_we_want_to_copy_to_destiny)
checkout_origin_repo(revision_number_that_we_want_to_copy_to_destiny)

author = get_author_name(revision_number_that_we_want_to_copy_to_destiny)

# In the event that the next revision removed files, we should 'svn rm name' before doing the copy.
remove_files_from_destiny_repo_that_were_removed_in_origin_repo()
Expand Down Expand Up @@ -190,8 +193,8 @@ def perform_conversion_operations(revision_number_that_we_want_to_copy_to_destin

# The final stage is to 'svn add *' everything and commit to destiny online repo. If this goes well, we
# would have succefully commited the intended revision.
puts "\n ====== Start svn add * , commit, and update ======\n"
system("cd /tmp/"+@svn_destiny_name +" && "+"svn status | grep '^\?' | awk '{print $2}' | xargs svn add "+ "&& svn commit -m '"+revision_number_that_we_want_to_copy_to_destiny+"'"+ " && "+"svn update")
puts "\n ====== Start svn add * , commit, and update. Using username: #{author} ======\n"
system("cd /tmp/"+@svn_destiny_name +" && "+"svn status | grep '^\?' | awk '{print $2}' | xargs svn add "+ "&& svn commit --username #{author} -m '"+revision_number_that_we_want_to_copy_to_destiny+"'"+ " && "+"svn update")
puts "\n ====== End svn add * , commit, and update ======\n"

end
Expand Down Expand Up @@ -226,6 +229,18 @@ def repo_online_revision(repo)
def list_directory(directory)
Dir.glob( File.join(directory, '**', '*') ) { |file| puts file }
end

def get_author_name(commit_number)
system("cd /tmp/#{@svn_origin_name} && svn log > #{@log_file_of_origin}")
string_file = ""
File.open("#{@log_file_of_origin}","r").each do |line|
string_file += line
end

line = /^[r]#{commit_number}+ [|] .*/.match(string_file).to_s
line_array = line.split(/ /)
author = line_array[2]
end

end
end

0 comments on commit 4756d84

Please sign in to comment.