git-review-notes 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Gemfile +9 -0
- data/Guardfile +7 -0
- data/README.md +20 -0
- data/Rakefile +1 -0
- data/bin/git-review +6 -0
- data/features/git-review.feature +19 -0
- data/features/step_definitions/git-review_steps.rb +7 -0
- data/features/support/env.rb +5 -0
- data/features/support/setup_sample_repository.rb +35 -0
- data/git-review.gemspec +32 -0
- data/lib/git_review/cli.rb +56 -0
- data/lib/git_review/git_ext.rb +11 -0
- data/lib/git_review/git_lib_fix_19.rb +16 -0
- data/lib/git_review/version.rb +3 -0
- data/lib/git_review.rb +6 -0
- data/tmp/.gitkeep +0 -0
- metadata +131 -0
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
guard 'cucumber', :cli => '--format pretty', :rvm => ['1.8.7', '1.9.3'] do
|
2
|
+
watch(%r{^features/.+\.feature$})
|
3
|
+
watch(%r{^features/support/.+\.rb$}) { 'features' }
|
4
|
+
watch(%r{\.rb$}) { 'features' }
|
5
|
+
watch(%r{bin/git-review-branch$}) { 'features' }
|
6
|
+
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
|
7
|
+
end
|
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# git-review
|
2
|
+
|
3
|
+
|
4
|
+
A git command to add notes with tag 'Reviewed-By: Reviewer \<reviewer@example.com\>'.
|
5
|
+
|
6
|
+
## Setup
|
7
|
+
|
8
|
+
gem install git-review
|
9
|
+
|
10
|
+
## Usage
|
11
|
+
|
12
|
+
There is two way to use it. First is to mark all commits from current branch as
|
13
|
+
reviewed.
|
14
|
+
|
15
|
+
git checkout branchname
|
16
|
+
git review
|
17
|
+
|
18
|
+
Second way is to mark commits individually.
|
19
|
+
|
20
|
+
git review HEAD~1 62ffa0a5
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/git-review
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Feature: Adding 'Reviewed-By:' note for reviewed commits
|
2
|
+
|
3
|
+
To have some formal way to see that particular git commits was reviewed by a developer
|
4
|
+
we need some tool that allows us to easily add a git note for each reviewed commit.
|
5
|
+
|
6
|
+
Scenario: Review a branch
|
7
|
+
When I run `git checkout branch-for-review`
|
8
|
+
And I run `git log`
|
9
|
+
Then the output should not contain "Reviewed-By:"
|
10
|
+
When I run `git review`
|
11
|
+
Then the output should contain "Reviewed-By: Reviewer <reviewer@example.com>"
|
12
|
+
And the output should contain "2 commits are marked as reviewed by you."
|
13
|
+
|
14
|
+
Scenario: Mark already merged commits
|
15
|
+
When I run `git log`
|
16
|
+
Then the output should not contain "Reviewed-By:"
|
17
|
+
When I run `git review commits HEAD HEAD~1`
|
18
|
+
Then the output should contain "Reviewed-By: Reviewer <reviewer@example.com>"
|
19
|
+
And the output should contain "2 commits are marked as reviewed by you."
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'active_support/core_ext/kernel/reporting'
|
2
|
+
|
3
|
+
Before do
|
4
|
+
setup_sample_repository
|
5
|
+
end
|
6
|
+
|
7
|
+
def setup_sample_repository
|
8
|
+
silence_stream(STDERR) do
|
9
|
+
silence_stream(STDOUT) do
|
10
|
+
system <<-SHELL
|
11
|
+
rm -rf tmp/aruba
|
12
|
+
mkdir tmp/aruba
|
13
|
+
cd tmp/aruba
|
14
|
+
git init
|
15
|
+
git config --add user.name Reviewer
|
16
|
+
git config --add user.email reviewer@example.com
|
17
|
+
touch README
|
18
|
+
git add README
|
19
|
+
git commit -m 'first commit.'
|
20
|
+
touch Gemfile
|
21
|
+
git add Gemfile
|
22
|
+
git commit -m 'second commit.'
|
23
|
+
git branch branch-for-review
|
24
|
+
git checkout branch-for-review
|
25
|
+
touch file1
|
26
|
+
git add file1
|
27
|
+
git commit -m 'commit 1 in branch-for-review.'
|
28
|
+
touch file2
|
29
|
+
git add file2
|
30
|
+
git commit -m 'commit 2 in branch-for-review.'
|
31
|
+
git checkout master
|
32
|
+
SHELL
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/git-review.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "git_review/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "git-review-notes"
|
7
|
+
s.version = GitReview::VERSION
|
8
|
+
s.authors = ["Aleksei Gusev"]
|
9
|
+
s.email = ["aleksei.gusev@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = "Adds git review command."
|
12
|
+
s.description = <<-DSC
|
13
|
+
git review will add note for each commit in current branch
|
14
|
+
with 'Reviewed-By: Reviewer <reviewer@example.com>.'
|
15
|
+
|
16
|
+
git review commits HEAD~1 648dbac marks individual commits as reviewed.
|
17
|
+
DSC
|
18
|
+
|
19
|
+
s.rubyforge_project = "git-review-notes"
|
20
|
+
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
23
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
24
|
+
s.require_paths = ["lib"]
|
25
|
+
|
26
|
+
s.add_runtime_dependency 'git'
|
27
|
+
s.add_runtime_dependency 'thor'
|
28
|
+
s.add_development_dependency "cucumber"
|
29
|
+
s.add_development_dependency "aruba", "= 0.4.6"
|
30
|
+
s.add_development_dependency "guard-cucumber"
|
31
|
+
s.add_development_dependency "active_support"
|
32
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'git_review'
|
3
|
+
|
4
|
+
module GitReview
|
5
|
+
class CLI < Thor
|
6
|
+
desc "review", "Add note with Reviewed-By: for each commit in current branch."
|
7
|
+
def review
|
8
|
+
raise "Current branch is master. Exiting..." if git.current_branch == 'master'
|
9
|
+
|
10
|
+
current_branch_commits = git.log.between("master", git.current_branch)
|
11
|
+
add_reviewed_by(current_branch_commits)
|
12
|
+
push_refs_notes
|
13
|
+
|
14
|
+
system "git log master..#{git.current_branch}"
|
15
|
+
display_report(current_branch_commits)
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "commits", "Add not with Reviewed-By: for specified commits separated by space."
|
19
|
+
def commits(*commits_shas)
|
20
|
+
commits = commits_shas.map {|sha| git.object(sha)}
|
21
|
+
add_reviewed_by(commits)
|
22
|
+
push_refs_notes
|
23
|
+
|
24
|
+
system "git log"
|
25
|
+
display_report(commits)
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def add_reviewed_by(commits)
|
32
|
+
commits.each do |commit|
|
33
|
+
note = "".tap do |msg|
|
34
|
+
msg << 'Reviewed-By: '
|
35
|
+
msg << "#{git.config('user.name')} <#{git.config('user.email')}>"
|
36
|
+
end
|
37
|
+
|
38
|
+
git.lib.add_note(commit, note)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def push_refs_notes
|
43
|
+
system "git push origin refs/notes/*"
|
44
|
+
end
|
45
|
+
|
46
|
+
def display_report(commits)
|
47
|
+
puts
|
48
|
+
say "#{commits.size} commits are marked as reviewed by you.", :green
|
49
|
+
end
|
50
|
+
|
51
|
+
def git
|
52
|
+
# @git ||= Git.open(".", :log => Logger.new(STDOUT))
|
53
|
+
@git ||= Git.open(".")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'git/lib'
|
2
|
+
|
3
|
+
# https://github.com/schacon/ruby-git/pull/35
|
4
|
+
class Git::Lib
|
5
|
+
def config_get(name)
|
6
|
+
do_get = lambda do |path|
|
7
|
+
command('config', ['--get', name])
|
8
|
+
end
|
9
|
+
|
10
|
+
if @git_dir
|
11
|
+
Dir.chdir(@git_dir, &do_get)
|
12
|
+
else
|
13
|
+
build_list.call
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/git_review.rb
ADDED
data/tmp/.gitkeep
ADDED
File without changes
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: git-review-notes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Aleksei Gusev
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-11-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: git
|
16
|
+
requirement: &7424420 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *7424420
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: thor
|
27
|
+
requirement: &7423740 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *7423740
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: cucumber
|
38
|
+
requirement: &7422680 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *7422680
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: aruba
|
49
|
+
requirement: &7438920 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - =
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.4.6
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *7438920
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: guard-cucumber
|
60
|
+
requirement: &7435920 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *7435920
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: active_support
|
71
|
+
requirement: &7434960 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *7434960
|
80
|
+
description: ! " git review will add note for each commit in current branch\n with
|
81
|
+
'Reviewed-By: Reviewer <reviewer@example.com>.'\n\n git review commits HEAD~1
|
82
|
+
648dbac marks individual commits as reviewed.\n"
|
83
|
+
email:
|
84
|
+
- aleksei.gusev@gmail.com
|
85
|
+
executables:
|
86
|
+
- git-review
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- Gemfile
|
92
|
+
- Guardfile
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- bin/git-review
|
96
|
+
- features/git-review.feature
|
97
|
+
- features/step_definitions/git-review_steps.rb
|
98
|
+
- features/support/env.rb
|
99
|
+
- features/support/setup_sample_repository.rb
|
100
|
+
- git-review.gemspec
|
101
|
+
- lib/git_review.rb
|
102
|
+
- lib/git_review/cli.rb
|
103
|
+
- lib/git_review/git_ext.rb
|
104
|
+
- lib/git_review/git_lib_fix_19.rb
|
105
|
+
- lib/git_review/version.rb
|
106
|
+
- tmp/.gitkeep
|
107
|
+
homepage: ''
|
108
|
+
licenses: []
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
115
|
+
requirements:
|
116
|
+
- - ! '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
121
|
+
requirements:
|
122
|
+
- - ! '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
requirements: []
|
126
|
+
rubyforge_project: git-review-notes
|
127
|
+
rubygems_version: 1.8.10
|
128
|
+
signing_key:
|
129
|
+
specification_version: 3
|
130
|
+
summary: Adds git review command.
|
131
|
+
test_files: []
|