Class: GitReviewBranch::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/git_review_branch/cli.rb

Instance Method Summary collapse

Instance Method Details

#reviewObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/git_review_branch/cli.rb', line 7

def review
  raise "Current branch is master. Exiting..." if git.current_branch == 'master'

  commits_to_review = git.log.between("master", git.current_branch)
  commits_to_review.each do |commit|
    note = "".tap do |msg|
      msg << 'Reviewed-By: '
      msg << "#{git.config('user.name')} <#{git.config('user.email')}>"
    end

    git.lib.add_note(commit, note)
  end

  system "git push origin refs/notes/*"
  system "git log master..#{git.current_branch}"
  puts
  say "#{commits_to_review.size} commits are marked as reviewed by you.", :green
end