simple-git-pair 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +16 -6
- data/lib/simple-git-pair/cli.rb +21 -1
- data/lib/simple-git-pair/helper.rb +24 -6
- data/lib/simple-git-pair/version.rb +2 -1
- data/spec/lib/simple-git-pair/cli_spec.rb +40 -0
- metadata +18 -7
data/README.md
CHANGED
@@ -1,26 +1,36 @@
|
|
1
|
+
[![Build Status](https://secure.travis-ci.org/fsproru/simple-git-pair.png)](http://travis-ci.org/fsproru/simple-git-pair)
|
2
|
+
|
1
3
|
## TL;DR
|
2
4
|
Simple way to add your pair to a git commit message.
|
3
5
|
|
4
6
|
## Description
|
5
|
-
Unlike many other gems it
|
7
|
+
Unlike many other gems it changes only user.name and does NOT change your email address in git config,
|
8
|
+
so Github can associate your commit to github account properly.
|
6
9
|
This is especially useful for Github graphs and statistics.
|
7
10
|
|
8
|
-
## Usage
|
9
|
-
|
11
|
+
## Installation and Usage
|
12
|
+
```sh
|
13
|
+
gem install simple-git-pair
|
14
|
+
git pair init
|
15
|
+
git pair nt ae # changes your git user.name to "Nicola Tesla & Alfred Einstein"
|
16
|
+
```
|
10
17
|
|
11
18
|
## Configuration
|
12
|
-
|
19
|
+
Keep your pairs in `.git_pairs` file in your home directory in yaml format, e.g.
|
13
20
|
```yml
|
14
21
|
nt: Nicola Tesla
|
15
22
|
ae: Alfred Einstein
|
16
23
|
...
|
17
24
|
```
|
18
25
|
|
26
|
+
## Supported Rubies
|
27
|
+
- 1.9.3
|
28
|
+
- 1.8.7
|
29
|
+
|
19
30
|
## Future Development
|
20
|
-
- git pair init # creates simple .git_pairs file
|
21
31
|
- git pair add <initial> <full_name> # adds an author to .git_pairs
|
22
32
|
- git pair delete <initial> # deletes a pair from .git_pairs
|
23
33
|
- git pair list # lists all available pairs
|
24
34
|
|
25
35
|
## Issues and Contributions
|
26
|
-
Feel free to submit issues or
|
36
|
+
Feel free to submit [issues](https://github.com/fsproru/simple-git-pair/issues), pull requests or [feedback](mailto: a.tamoykin@gmail.com)
|
data/lib/simple-git-pair/cli.rb
CHANGED
@@ -14,13 +14,33 @@ module SimpleGitPair
|
|
14
14
|
exit 0
|
15
15
|
end
|
16
16
|
|
17
|
+
if opts.delete "init"
|
18
|
+
exit(init_cmd ? 0 : 1)
|
19
|
+
end
|
20
|
+
|
17
21
|
unless Helper.pairs_file_exists?
|
18
22
|
Helper.complain_about_pairs_file
|
19
23
|
exit 1
|
20
24
|
end
|
21
25
|
|
22
|
-
|
26
|
+
begin
|
27
|
+
system "git config user.name '#{(Helper.names_for ARGV).join ' & '}'"
|
28
|
+
rescue Helper::NotFoundException => ex
|
29
|
+
puts ex.message
|
30
|
+
exit 1
|
31
|
+
end
|
32
|
+
|
23
33
|
system "git config user.name" # output current username
|
24
34
|
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def init_cmd
|
39
|
+
if Helper.pairs_file_exists?
|
40
|
+
Helper.say_pairs_file_exists
|
41
|
+
else
|
42
|
+
Helper.create_pairs_file
|
43
|
+
end
|
44
|
+
end
|
25
45
|
end
|
26
46
|
end
|
@@ -1,33 +1,47 @@
|
|
1
1
|
require 'yaml'
|
2
|
+
require 'simple-git-pair/version'
|
2
3
|
|
3
4
|
module SimpleGitPair
|
4
5
|
module Helper
|
6
|
+
|
7
|
+
class NotFoundException < Exception; end
|
8
|
+
|
5
9
|
class << self
|
6
|
-
|
10
|
+
PAIRS_FILE_NAME = '.git_pairs'
|
11
|
+
PAIRS_FILE_PATH = File.expand_path("~/#{PAIRS_FILE_NAME}")
|
7
12
|
|
8
13
|
def show_help
|
9
14
|
puts <<-EOS
|
10
15
|
|
11
|
-
|
16
|
+
#{SUMMARY}
|
12
17
|
Usage: git-pair <initial1> <initial2>
|
18
|
+
|
19
|
+
Commands:
|
20
|
+
init - creates sample #{PAIRS_FILE_NAME} config
|
13
21
|
EOS
|
14
22
|
end
|
15
23
|
|
16
24
|
def complain_about_pairs_file
|
17
25
|
puts <<-EOS
|
18
26
|
|
19
|
-
Please create #{
|
27
|
+
Please create #{PAIRS_FILE_NAME} file in your home directory in yaml format:
|
20
28
|
ae: Alfred Einstein
|
21
29
|
nt: Nikola Tesla
|
22
30
|
EOS
|
23
31
|
end
|
24
32
|
|
33
|
+
def say_pairs_file_exists
|
34
|
+
puts <<-EOS
|
35
|
+
#{PAIRS_FILE_PATH} already exists. You're good to go.
|
36
|
+
EOS
|
37
|
+
end
|
38
|
+
|
25
39
|
def names_for args
|
26
|
-
pairs = YAML.load_file
|
40
|
+
pairs = YAML.load_file PAIRS_FILE_PATH
|
27
41
|
|
28
42
|
names = []
|
29
43
|
args.each do |opt|
|
30
|
-
raise "There is no entry for #{opt} in #{
|
44
|
+
raise NotFoundException.new "There is no entry for #{opt} in #{PAIRS_FILE_PATH}" unless pairs[opt]
|
31
45
|
names << pairs[opt]
|
32
46
|
end
|
33
47
|
|
@@ -35,7 +49,11 @@ module SimpleGitPair
|
|
35
49
|
end
|
36
50
|
|
37
51
|
def pairs_file_exists?
|
38
|
-
File.exist?
|
52
|
+
File.exist? PAIRS_FILE_PATH
|
53
|
+
end
|
54
|
+
|
55
|
+
def create_pairs_file
|
56
|
+
File.open(PAIRS_FILE_PATH, "w") { |f| f.write "nt: Nikola Tesla\nae: Alfred Einstein" }
|
39
57
|
end
|
40
58
|
end
|
41
59
|
end
|
@@ -24,6 +24,14 @@ describe SimpleGitPair::Cli do
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
context "'init' command" do
|
28
|
+
let(:opts) { ['init'] }
|
29
|
+
it "runs init cmd" do
|
30
|
+
cli.should_receive :init_cmd
|
31
|
+
expect { subject }.to raise_error SystemExit
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
27
35
|
context "there is NO pairs file" do
|
28
36
|
before { SimpleGitPair::Helper.stub(:pairs_file_exists?).and_return false }
|
29
37
|
let(:opts) { ["some_initials"] }
|
@@ -59,6 +67,38 @@ describe SimpleGitPair::Cli do
|
|
59
67
|
subject
|
60
68
|
end
|
61
69
|
end
|
70
|
+
|
71
|
+
context "and passed initial is unknown" do
|
72
|
+
let(:opts) { ['unknown_dude'] }
|
73
|
+
let(:ex) { SimpleGitPair::Helper::NotFoundException.new "I don't know about #{opts.first}" }
|
74
|
+
before {
|
75
|
+
SimpleGitPair::Helper.stub(:pairs_file_exists?).and_return true
|
76
|
+
SimpleGitPair::Helper.stub(:names_for).and_raise ex
|
77
|
+
cli.stub! :system
|
78
|
+
cli.should_receive(:puts).with(ex.message)
|
79
|
+
}
|
80
|
+
it { expect { subject }.to raise_error SystemExit }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "#init_cmd" do
|
85
|
+
subject { cli.send :init_cmd }
|
86
|
+
|
87
|
+
context "pairs file already exists" do
|
88
|
+
before { SimpleGitPair::Helper.stub(:pairs_file_exists?).and_return true }
|
89
|
+
it "complains and exit" do
|
90
|
+
SimpleGitPair::Helper.should_receive :say_pairs_file_exists
|
91
|
+
subject.should be_false
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context "there is no pairs file" do
|
96
|
+
before { SimpleGitPair::Helper.stub(:pairs_file_exists?).and_return false }
|
97
|
+
it "creates a pairs file" do
|
98
|
+
SimpleGitPair::Helper.should_receive(:create_pairs_file).and_return true
|
99
|
+
subject.should be_true
|
100
|
+
end
|
101
|
+
end
|
62
102
|
end
|
63
103
|
end
|
64
104
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple-git-pair
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70241657198260 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,21 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70241657198260
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake
|
27
|
+
requirement: &70241657197660 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70241657197660
|
25
36
|
- !ruby/object:Gem::Dependency
|
26
37
|
name: debugger
|
27
|
-
requirement: &
|
38
|
+
requirement: &70241657197160 !ruby/object:Gem::Requirement
|
28
39
|
none: false
|
29
40
|
requirements:
|
30
41
|
- - ! '>='
|
@@ -32,7 +43,7 @@ dependencies:
|
|
32
43
|
version: '0'
|
33
44
|
type: :development
|
34
45
|
prerelease: false
|
35
|
-
version_requirements: *
|
46
|
+
version_requirements: *70241657197160
|
36
47
|
description: Changes only user.name setting in git config, so github
|
37
48
|
can still understand under which account a code was committed
|
38
49
|
email:
|
@@ -74,7 +85,7 @@ rubyforge_project:
|
|
74
85
|
rubygems_version: 1.8.10
|
75
86
|
signing_key:
|
76
87
|
specification_version: 3
|
77
|
-
summary:
|
88
|
+
summary: Simple way to add your pair to a git commit message
|
78
89
|
test_files:
|
79
90
|
- spec/lib/simple-git-pair/cli_spec.rb
|
80
91
|
- spec/lib/simple-git-pair/helper_spec.rb
|