Class: GitChange::Author

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/git_change/author.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



13
14
15
# File 'lib/git_change/author.rb', line 13

def self.source_root
  File.dirname(__FILE__)
end

Instance Method Details

#clone_repo_bareObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/git_change/author.rb', line 17

def clone_repo_bare
  # get remote url for current repo
  remote_url = GitChange::Util.git_remote_url
  if remote_url.empty?
    puts "You need to have remote repository to work on".colorize(:red)
    return
  end
  if File.directory? "temp_repo"
    puts "temp_repo directory already exists".colorize(:red)
    return
  end
  # git clone bare to temp_repo to work on
  system "git clone --bare #{remote_url} temp_repo"
  puts "First step: clone the bare repository is done".colorize(:green)
end

#puts_command_to_finishObject



53
54
55
56
57
58
59
# File 'lib/git_change/author.rb', line 53

def puts_command_to_finish
  puts "After you review the change, you can run the command below"
  puts "inside temp_repo, after that remove the temp_repo"
  puts "============================================================" 
  puts "git push --force --tags origin 'refs/heads/*'"
  puts "============================================================" 
end

#run_change_author_scriptObject



33
34
35
36
37
38
39
40
# File 'lib/git_change/author.rb', line 33

def run_change_author_script
  # create script
  template "templates/change_author.tt", "temp_repo/change_author.sh"
  inside "temp_repo" do
    # run the script
    run "sh ./change_author.sh"
  end
end

#set_local_configObject



42
43
44
45
46
47
48
49
50
51
# File 'lib/git_change/author.rb', line 42

def set_local_config
  old_name = GitChange::Util.user_name
  old_email = options[:old_email]
  puts "change local config user.name from #{old_name} to #{name}".
    colorize(:green)
  puts "change local config user.email from #{old_email} to #{email}".
    colorize(:green)
  `git config user.name #{name}`
  `git config user.email #{email}`
end