git-pairing 0.2.5 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +82 -0
- data/bin/git-pair +53 -50
- data/bin/git-solo +44 -0
- data/bin/git-whoami +18 -0
- data/lib/commands.rb +37 -0
- data/lib/helper.rb +111 -0
- metadata +52 -19
- data/lib/commands/add.rb +0 -20
- data/lib/commands/rm.rb +0 -17
- data/lib/commands/set.rb +0 -64
- data/lib/commands/show.rb +0 -27
- data/lib/commands/solo.rb +0 -10
- data/lib/git-pair.rb +0 -7
- data/lib/pairs.rb +0 -55
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDI5NGIxODQxZWYxMzYyZjI2NDYxNTVhNzRmMGZjODUzZWM1ZjI4Zg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTQ1MmU4NmM0YmY1Njg4MTE5OWQxZTFmYmEyMDU4YTk0ZTU3ODNmNw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
N2IwNGFmOGMwMzhjMDc4MDg1YjY3NjgwMmE4OGZiM2YzZWRhNTcyMzZlNjky
|
10
|
+
Zjk2ODBlZjExNTAwNjY1NDdhMjk2NTY1YmZlNTEyNmU0ZmM4YWM4M2EyNDM4
|
11
|
+
MjBhYzgxZGQzOTQ5Zjk1MDU4ODdiNzM2NTNhOWRiMTQyZTkxYmQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDlmOTY0MGRiN2NiODljNzNmZTdhYjdjOGIwNGU4ZGMwZjE1NDc0MDhjNTBl
|
14
|
+
YTU3OWZhNDcxZjZiZTg3ZDdhMGZhNTEyZjFkOGNjZTUwZDBmOTc4ODU5ZDIx
|
15
|
+
N2JlNDMxZjVlMjU3YzA5MmFhYzY3NGYzZmU2ZDM5ZmI3ZDExNmM=
|
data/README.md
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# INTRO
|
2
|
+
|
3
|
+
Share code authorship when pairing and using git/github.
|
4
|
+
Works well with my fork of promptula to show which git pair is currently
|
5
|
+
configured in a git repo.
|
6
|
+
|
7
|
+
# Features
|
8
|
+
|
9
|
+
* adds new commands to git, `git pair`, `git whoami`, and `git solo`
|
10
|
+
* changes the git config `[user] name` to list multiple commit authors, and remembers partners per repository
|
11
|
+
* maintains a list of pairing partners, so that you can specify multiple commit authors by their initials
|
12
|
+
* prompts to configure new partners as needed
|
13
|
+
* reverts back to original global settings
|
14
|
+
* compliments [promptula](http://github.com/wballard/promptula)
|
15
|
+
|
16
|
+
See help for more details and available options on the commands
|
17
|
+
|
18
|
+
```
|
19
|
+
$ git pair -h
|
20
|
+
$ git whoami -h
|
21
|
+
$ git solo -h
|
22
|
+
```
|
23
|
+
|
24
|
+
# Installing
|
25
|
+
|
26
|
+
To grab the latest stable release `gem install git-pairing`
|
27
|
+
|
28
|
+
Or, clone this repo and execute the following command in your
|
29
|
+
terminal/console of choice
|
30
|
+
|
31
|
+
```
|
32
|
+
$ gem install git-pairing
|
33
|
+
```
|
34
|
+
|
35
|
+
# Customizing
|
36
|
+
|
37
|
+
### Tweaking Promptula Command Prompt
|
38
|
+
|
39
|
+
When promptula is installed along side git-pairing, it will display the
|
40
|
+
pairing partners configured in a repo on the command line. Installing
|
41
|
+
promptula `promptula --install` adds a line to your
|
42
|
+
.bash_profile/.bashrc `export PROMPT_COMMAND='echo -ne $(promptula)'`.
|
43
|
+
This allows users to keep whatever prompt they have already in place,
|
44
|
+
but augments it with additional info when you are in a git repo. By
|
45
|
+
default, the promptula info is at the beginning of your prompt.
|
46
|
+
|
47
|
+
I prefer to have the path to my cwd in my prompt with promptula info at
|
48
|
+
the end. To do that, I simply replaced the export command created by
|
49
|
+
promptula in the .bash_profile/.bashrc with
|
50
|
+
|
51
|
+
```
|
52
|
+
export PS1="\$(pwd) \$(promoptula) "
|
53
|
+
```
|
54
|
+
|
55
|
+
### Configuration
|
56
|
+
|
57
|
+
The first time that `git pair` is executed, it will create a config file
|
58
|
+
in the user's home directory `~/.pairs`
|
59
|
+
|
60
|
+
This is just a yaml file that you can edit manually or update via the
|
61
|
+
available commands (e.g., `git pair --add sq`). Included in the config is
|
62
|
+
the default delimiters used when setting the pair names, email
|
63
|
+
addresses, and partner initials
|
64
|
+
into the git config. Feel free to update these as well if the defaults
|
65
|
+
do not suit your fancy.
|
66
|
+
|
67
|
+
# Known Issues
|
68
|
+
|
69
|
+
* Does not currently work on Windows... Ubuntu and Mac OS X seem fine
|
70
|
+
* May not play entirely nicely with github since they use the commiter's
|
71
|
+
name and email address to generate statistics and links
|
72
|
+
* Will not play nice with [Chris Kampmeier's
|
73
|
+
git-pair](https://github.com/chrisk/git-pair) gem since it uses similar
|
74
|
+
git command syntax (namely `git pair`)
|
75
|
+
|
76
|
+
# Building
|
77
|
+
|
78
|
+
The included Rakefile will build the git-pairing gem, e.g.,
|
79
|
+
|
80
|
+
```
|
81
|
+
$ rake
|
82
|
+
```
|
data/bin/git-pair
CHANGED
@@ -1,60 +1,63 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require '
|
4
|
-
require '
|
3
|
+
require 'trollop'
|
4
|
+
require 'yaml/store'
|
5
|
+
require 'helper.rb'
|
6
|
+
require 'commands.rb'
|
7
|
+
require 'highline/import'
|
8
|
+
require 'paint'
|
9
|
+
require 'pp'
|
5
10
|
|
6
|
-
|
11
|
+
# config file is put into the user's home directory
|
12
|
+
path_to_conf = File.join(File.expand_path(ENV['HOME']),'.pairs')
|
13
|
+
pairs_conf = GitPairs::Helper.init(path_to_conf)
|
7
14
|
|
8
|
-
|
9
|
-
|
10
|
-
wrap_help_text :verbatim
|
15
|
+
# Check if we are in a git repo
|
16
|
+
Trollop::die "Not in a git repo" unless system 'git status > /dev/null 2>/dev/null'
|
11
17
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
pre do |global,command,options,args|
|
16
|
-
# Pre logic here
|
17
|
-
# Return true to proceed; false to abort and not call the chosen command
|
18
|
-
# Use skips_pre before a command to skip this block
|
19
|
-
# on that command only
|
20
|
-
|
21
|
-
# Create config if it doesn't already exist
|
22
|
-
unless File.exists?(CFG_FILE)
|
23
|
-
name = `git config --global --get user.name`
|
24
|
-
initials = ""
|
25
|
-
name.strip.downcase.split(/ /).each { |n| initials << n.split(//)[0] }
|
26
|
-
email = `git config --get user.email`
|
27
|
-
username = email.split("@")[0]
|
28
|
-
default_conf = YAML::Store.new(CFG_FILE)
|
29
|
-
default_conf.transaction do
|
30
|
-
default_conf["pairs"] = {"#{initials}" => {'name'=>"#{name.strip}", 'username'=>"#{username}", 'email'=>"#{email.strip}"} }
|
31
|
-
default_conf["delimiters"] = {"name" => " / ", "initials" => " "}
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# Load .pairs config
|
36
|
-
if (File.exist?(CFG_FILE))
|
37
|
-
$pairs_conf = YAML::load(File.open(CFG_FILE, 'r'))
|
38
|
-
else
|
39
|
-
exit_now!("No ~/.pairs config file found")
|
40
|
-
end
|
41
|
-
|
42
|
-
true
|
43
|
-
end
|
18
|
+
opts = Trollop::options do
|
19
|
+
banner <<-EOS
|
44
20
|
|
45
|
-
|
46
|
-
# Post logic here
|
47
|
-
# Use skips_post before a command to skip this
|
48
|
-
# block on that command only
|
49
|
-
end
|
21
|
+
Enables you to attribute git code commits to multiple authors
|
50
22
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
23
|
+
Usage:
|
24
|
+
git pair <user-initials-1> <user-initials-2> [<user-initials-3> ...]
|
25
|
+
git pair [-a | --add] <user-initials-1> [<user-initials-2> ...]
|
26
|
+
git pair [-d | --delete] <user-initials-1> [<user-initials-2> ...]
|
27
|
+
git pair [-s | --show]
|
28
|
+
git pair -h
|
29
|
+
|
30
|
+
Options are mutually exclusive:
|
31
|
+
|
32
|
+
EOS
|
33
|
+
opt :add, "Configures new pairing partners without modifying the existing git config", :type=>:strings
|
34
|
+
opt :delete, "Delete pairing partners from the ~/.pairs config without modifying the existing git config", :type=>:strings
|
35
|
+
opt :show, "Display the current ~/.pairs config"
|
55
36
|
end
|
56
37
|
|
57
|
-
|
58
|
-
|
38
|
+
too_many = (opts[:show_given] && opts[:add_given]) || (opts[:show_given] && opts[:delete_given]) || (opts[:add_given] && opts[:delete_given])
|
39
|
+
Trollop::die "Options are mutually exclusive - please enter only one" if too_many
|
40
|
+
|
41
|
+
if opts[:show_given]
|
42
|
+
GitPairs::Helper.whoami
|
43
|
+
puts "Pairs Config >"
|
44
|
+
puts ""
|
45
|
+
pp pairs_conf
|
46
|
+
puts ""
|
47
|
+
elsif opts[:add_given]
|
48
|
+
GitPairs::Commands.add(pairs_conf, path_to_conf, opts[:add])
|
49
|
+
puts "Pairs Config >"
|
50
|
+
puts ""
|
51
|
+
pp pairs_conf
|
52
|
+
puts ""
|
53
|
+
elsif opts[:delete_given]
|
54
|
+
GitPairs::Commands.rm(pairs_conf, path_to_conf, opts[:delete])
|
55
|
+
puts "Pairs Config >"
|
56
|
+
puts ""
|
57
|
+
pp pairs_conf
|
58
|
+
puts ""
|
59
|
+
else
|
60
|
+
GitPairs::Commands.set(pairs_conf, path_to_conf, ARGV.uniq)
|
61
|
+
GitPairs::Helper.whoami
|
62
|
+
end
|
59
63
|
|
60
|
-
exit run(ARGV)
|
data/bin/git-solo
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'trollop'
|
4
|
+
require 'helper.rb'
|
5
|
+
require 'paint'
|
6
|
+
|
7
|
+
opts = Trollop::options do
|
8
|
+
banner <<-EOS
|
9
|
+
|
10
|
+
Attribute git code commits to a single author
|
11
|
+
|
12
|
+
Usage:
|
13
|
+
git solo [<user-initials>]
|
14
|
+
|
15
|
+
With no initials - removes user info from local git repo's config, global user config settings will be used
|
16
|
+
With initials - replaces local git repo config with info for that user
|
17
|
+
|
18
|
+
EOS
|
19
|
+
end
|
20
|
+
|
21
|
+
# config file is put into the user's home directory
|
22
|
+
initials = ARGV
|
23
|
+
pairs_conf = GitPairs::Helper.init(File.join(File.expand_path(ENV['HOME']),'.pairs'))
|
24
|
+
|
25
|
+
Trollop::die "Not in a git repo" unless system 'git status > /dev/null 2>/dev/null'
|
26
|
+
|
27
|
+
if initials.nil? || initials.empty?
|
28
|
+
# revert to global git config
|
29
|
+
`git config --unset-all user.name > /dev/null 2>/dev/null`
|
30
|
+
`git config --unset-all user.email > /dev/null 2>/dev/null`
|
31
|
+
`git config --unset-all user.initials > /dev/null 2>/dev/null`
|
32
|
+
`git config --remove-section user > /dev/null 2>/dev/null`
|
33
|
+
elsif GitPairs::Helper.exists?(pairs_conf, initials[0])
|
34
|
+
# set local git config to single configured partner
|
35
|
+
author = GitPairs::Helper.fetch(pairs_conf, initials[0])
|
36
|
+
`git config user.name "#{author['name']}"`
|
37
|
+
`git config user.email "#{author['email']}"`
|
38
|
+
`git config user.initials "#{initials[0]}"`
|
39
|
+
else
|
40
|
+
puts ""
|
41
|
+
puts Paint["There is no pairing partner configured for: #{initials[0]}", :red]
|
42
|
+
end
|
43
|
+
|
44
|
+
GitPairs::Helper.whoami
|
data/bin/git-whoami
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'trollop'
|
4
|
+
require 'helper.rb'
|
5
|
+
|
6
|
+
opts = Trollop::options do
|
7
|
+
banner <<-EOS
|
8
|
+
|
9
|
+
Displays user info if it exists for the local git repo, otherwise displays global git config user info
|
10
|
+
|
11
|
+
Usage:
|
12
|
+
git whoami
|
13
|
+
|
14
|
+
EOS
|
15
|
+
end
|
16
|
+
|
17
|
+
Trollop::die "Please ensure that git is installed before using 'git whoami'" unless system 'git --version > /dev/null 2>/dev/null'
|
18
|
+
GitPairs::Helper.whoami
|
data/lib/commands.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'paint'
|
2
|
+
|
3
|
+
module GitPairs
|
4
|
+
class Commands
|
5
|
+
def self.add(conf, path_to_conf, partners)
|
6
|
+
partners.uniq.each do |partner|
|
7
|
+
GitPairs::Helper.add(conf, path_to_conf, partner)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.rm(conf, path_to_conf, partners)
|
12
|
+
partners.uniq.each do |partner|
|
13
|
+
GitPairs::Helper.delete(conf, path_to_conf, partner)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.set(conf, path_to_conf, partners)
|
18
|
+
if partners.size < 2
|
19
|
+
puts ""
|
20
|
+
puts Paint["Please supply at least 2 sets of initials", :red]
|
21
|
+
Trollop::die "Wrong number of arguments"
|
22
|
+
end
|
23
|
+
authors = []
|
24
|
+
partners.uniq.each do |partner|
|
25
|
+
unless GitPairs::Helper.exists?(conf, partner)
|
26
|
+
GitPairs::Helper.add(conf, path_to_conf, partner)
|
27
|
+
end
|
28
|
+
#concatenate each partner's info into delimited strings
|
29
|
+
author = GitPairs::Helper.fetch(conf, partner)
|
30
|
+
name = author["username"]
|
31
|
+
email = author["email"]
|
32
|
+
authors << ["#{name}","#{partner}", "#{email}"]
|
33
|
+
end
|
34
|
+
GitPairs::Helper.set(conf, authors)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/helper.rb
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'yaml/store'
|
2
|
+
require 'paint'
|
3
|
+
require 'highline/import'
|
4
|
+
|
5
|
+
module GitPairs
|
6
|
+
class Helper
|
7
|
+
# Functions for manipulating the .pairs config file
|
8
|
+
|
9
|
+
def self.init(path_to_conf)
|
10
|
+
# Create config if it doesn't already exist
|
11
|
+
unless File.exists?(path_to_conf)
|
12
|
+
Trollop::die "Please ensure that git is installed before proceeding" unless system 'git --version > /dev/null 2>/dev/null'
|
13
|
+
puts Paint["initializing git-pairing for the first time...", :yellow]
|
14
|
+
name = `git config --global --get user.name`
|
15
|
+
initials = ""
|
16
|
+
name.strip.downcase.split(/ /).each { |n| initials << n.split(//)[0] }
|
17
|
+
email = `git config --global --get user.email`
|
18
|
+
username = email.split("@")[0]
|
19
|
+
default_conf = YAML::Store.new(path_to_conf)
|
20
|
+
default_conf.transaction do
|
21
|
+
default_conf["pairs"] = {"#{initials}" => {'name'=>"#{name.strip}", 'username'=>"#{username}", 'email'=>"#{email.strip}"} }
|
22
|
+
default_conf["delimiters"] = {"name" => " / ", "initials" => " ", "email" => " , "}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Update older confs with recently added settings
|
27
|
+
tmp_conf = YAML::load(File.open(path_to_conf))
|
28
|
+
update_conf = YAML::Store.new(path_to_conf)
|
29
|
+
update_conf.transaction do
|
30
|
+
update_conf["delimiters"] = tmp_conf["delimiters"] || {}
|
31
|
+
update_conf["delimiters"]["name"] = (tmp_conf["delimiters"] && tmp_conf["delimiters"]["name"]) || " / "
|
32
|
+
update_conf["delimiters"]["initials"] = (tmp_conf["delimiters"] && tmp_conf["delimiters"]["initials"]) || " "
|
33
|
+
update_conf["delimiters"]["email"] = (tmp_conf["delimiters"] && tmp_conf["delimiters"]["email"]) || " , "
|
34
|
+
end
|
35
|
+
|
36
|
+
return YAML::load(File.open(path_to_conf))
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.whoami
|
40
|
+
user = `git config --get user.name`.strip
|
41
|
+
email = `git config --get user.email`.strip
|
42
|
+
puts ""
|
43
|
+
puts "current git config >"
|
44
|
+
puts Paint["Name: #{user}", :yellow]
|
45
|
+
puts Paint["Email: #{email}", :yellow]
|
46
|
+
puts ""
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.add(conf, path_to_conf, initials)
|
50
|
+
if self.exists?(conf, initials)
|
51
|
+
puts ""
|
52
|
+
puts Paint["Pairing Partner '#{initials}' already exists", :red]
|
53
|
+
puts Paint["To replace '#{initials}', first execute: git pair -d #{initials}", :yellow]
|
54
|
+
else
|
55
|
+
puts ""
|
56
|
+
puts Paint["Please provide info for: #{initials}", :yellow]
|
57
|
+
name = ask("Full Name: ")
|
58
|
+
user = ask("Git Username: ")
|
59
|
+
#just in case they supply email address
|
60
|
+
user = user.split('@')[0]
|
61
|
+
email = ask("Email: ")
|
62
|
+
partner = {initials => {'name' => name, 'username' => user, 'email' => email}}
|
63
|
+
conf["pairs"].update(partner)
|
64
|
+
temp_conf = YAML::Store.new(path_to_conf)
|
65
|
+
temp_conf.transaction do
|
66
|
+
temp_conf["pairs"] = conf["pairs"]
|
67
|
+
end
|
68
|
+
puts ""
|
69
|
+
puts Paint["Added '#{initials}' to list of available pairs", :yellow]
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.set(conf, authors)
|
74
|
+
authors.sort!
|
75
|
+
sorted_authors = ""
|
76
|
+
sorted_initials = ""
|
77
|
+
sorted_emails = ""
|
78
|
+
authors.each do |a|
|
79
|
+
sorted_authors << a[0]
|
80
|
+
sorted_initials << a[1]
|
81
|
+
sorted_emails << a[2]
|
82
|
+
if authors.index(a) < authors.size-1
|
83
|
+
sorted_authors << conf['delimiters']['name']
|
84
|
+
sorted_initials << conf['delimiters']['initials']
|
85
|
+
sorted_emails << conf['delimiters']['email']
|
86
|
+
end
|
87
|
+
cmd_git = `git config user.name "#{sorted_authors}"`
|
88
|
+
cmd_git = `git config user.initials "#{sorted_initials}"`
|
89
|
+
cmd_git = `git config user.email "#{sorted_emails}"`
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.exists?(conf, initials)
|
94
|
+
return conf["pairs"].include?(initials)
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.fetch(conf, initials)
|
98
|
+
return conf["pairs"][initials]
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.delete(conf, path_to_conf, initials)
|
102
|
+
if conf["pairs"].include?(initials)
|
103
|
+
conf["pairs"].delete(initials)
|
104
|
+
temp_conf = YAML::Store.new(path_to_conf)
|
105
|
+
temp_conf.transaction do
|
106
|
+
temp_conf["pairs"] = conf["pairs"]
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-pairing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Quince
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-04-
|
11
|
+
date: 2013-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: trollop
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: paint
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: awesome_print
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,39 +81,44 @@ dependencies:
|
|
53
81
|
- !ruby/object:Gem::Version
|
54
82
|
version: '0'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
84
|
+
name: rdoc
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
58
86
|
requirements:
|
59
|
-
- - '
|
87
|
+
- - ! '>='
|
60
88
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
62
|
-
type: :
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
63
91
|
prerelease: false
|
64
92
|
version_requirements: !ruby/object:Gem::Requirement
|
65
93
|
requirements:
|
66
|
-
- - '
|
94
|
+
- - ! '>='
|
67
95
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
69
|
-
description:
|
96
|
+
version: '0'
|
97
|
+
description: Allows you to attribute code commits to multiple authors
|
70
98
|
email: steve.quince@gmail.com
|
71
99
|
executables:
|
72
100
|
- git-pair
|
101
|
+
- git-solo
|
102
|
+
- git-whoami
|
73
103
|
extensions: []
|
74
|
-
extra_rdoc_files:
|
104
|
+
extra_rdoc_files:
|
105
|
+
- README.md
|
75
106
|
files:
|
76
107
|
- bin/git-pair
|
77
|
-
-
|
78
|
-
-
|
79
|
-
- lib/commands
|
80
|
-
- lib/
|
81
|
-
-
|
82
|
-
- lib/git-pair.rb
|
83
|
-
- lib/pairs.rb
|
108
|
+
- bin/git-solo
|
109
|
+
- bin/git-whoami
|
110
|
+
- lib/commands.rb
|
111
|
+
- lib/helper.rb
|
112
|
+
- README.md
|
84
113
|
homepage: https://github.com/squince/git-pairing
|
85
114
|
licenses: []
|
86
115
|
metadata: {}
|
87
116
|
post_install_message:
|
88
|
-
rdoc_options:
|
117
|
+
rdoc_options:
|
118
|
+
- --title
|
119
|
+
- git-pairing
|
120
|
+
- --main
|
121
|
+
- README.md
|
89
122
|
require_paths:
|
90
123
|
- lib
|
91
124
|
- lib
|
@@ -104,5 +137,5 @@ rubyforge_project:
|
|
104
137
|
rubygems_version: 2.0.2
|
105
138
|
signing_key:
|
106
139
|
specification_version: 4
|
107
|
-
summary:
|
140
|
+
summary: ''
|
108
141
|
test_files: []
|
data/lib/commands/add.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
desc 'adds new pairing partners: $git pair add <user-initials-1> [<user-initials-2> ...]'
|
2
|
-
command :add do |c|
|
3
|
-
c.action do |global_options,options,args|
|
4
|
-
partners = ""
|
5
|
-
if args.empty?
|
6
|
-
list = ask("Please enter a space separated list of partner initials to configure")
|
7
|
-
partners = list.strip.split(/ /)
|
8
|
-
else
|
9
|
-
partners = args
|
10
|
-
end
|
11
|
-
partners.uniq.each do |partner|
|
12
|
-
unless GitPairs::Pairs.exists?(partner)
|
13
|
-
GitPairs::Pairs.add(partner)
|
14
|
-
else
|
15
|
-
puts "Pairing Partner '#{partner}' already exists"
|
16
|
-
puts"To replace '#{partner}', first execute: git pair rm #{partner}"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
data/lib/commands/rm.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
desc 'removes one or more pairing partners: $git pair rm <user-initials-1> [<user-initials-2> ...]'
|
2
|
-
command :rm do |c|
|
3
|
-
c.action do |global_options,options,args|
|
4
|
-
unless args.empty?
|
5
|
-
args.uniq.each do |partner|
|
6
|
-
unless GitPairs::Pairs.exists?(partner)
|
7
|
-
puts"There is no pairing partner configured for: #{partner}"
|
8
|
-
else
|
9
|
-
GitPairs::Pairs.delete(partner)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
else
|
13
|
-
exit_now!("Wrong Number of Arguments - please provide at least one partner to remove")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
data/lib/commands/set.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
desc 'switches pairing partners: $git pair set <user-initials-1> [<user-initials-2> ...]'
|
2
|
-
command :set do |c|
|
3
|
-
c.action do |global_options,options,args|
|
4
|
-
# Check if we are in a git repo
|
5
|
-
unless system 'git status > /dev/null 2>/dev/null'
|
6
|
-
puts"Not in a git repo"
|
7
|
-
else
|
8
|
-
#puts "in set"
|
9
|
-
unless !args.empty?
|
10
|
-
exit_now!("Wrong Number of Arguments - please provide pairing partners")
|
11
|
-
else
|
12
|
-
#puts "args not empty"
|
13
|
-
#add pair to conf
|
14
|
-
authors = []
|
15
|
-
solo_author = ""
|
16
|
-
solo_email = ""
|
17
|
-
solo_initials = ""
|
18
|
-
size = args.uniq.size
|
19
|
-
args.uniq.each do |partner|
|
20
|
-
unless GitPairs::Pairs.exists?(partner)
|
21
|
-
GitPairs::Pairs.add(partner)
|
22
|
-
end
|
23
|
-
#puts "in concat"
|
24
|
-
if size > 1
|
25
|
-
#concatenate each partner's username into git config "author"
|
26
|
-
@author = GitPairs::Pairs.fetch(partner)["username"]
|
27
|
-
authors << ["#{@author}","#{partner}"]
|
28
|
-
else # exactly one author provided
|
29
|
-
solo = GitPairs::Pairs.fetch(partner)
|
30
|
-
solo_author = solo["name"]
|
31
|
-
solo_email = solo["email"]
|
32
|
-
solo_initials = partner
|
33
|
-
end
|
34
|
-
end
|
35
|
-
unless authors.empty?
|
36
|
-
authors.sort!
|
37
|
-
#puts"authors: #{authors}"
|
38
|
-
sorted_authors = ""
|
39
|
-
sorted_initials = ""
|
40
|
-
authors.each do |a|
|
41
|
-
sorted_authors << a[0]
|
42
|
-
sorted_initials << a[1]
|
43
|
-
if size > 1 && authors.index(a) < size-1
|
44
|
-
sorted_authors << $pairs_conf['delimiters']['name'] #" / "
|
45
|
-
sorted_initials << $pairs_conf['delimiters']['initials'] #" "
|
46
|
-
end
|
47
|
-
end
|
48
|
-
#puts"sorted authors: #{sorted_authors}"
|
49
|
-
cmd_git = `git config user.name "#{sorted_authors}"`
|
50
|
-
cmd_git = `git config user.initials "#{sorted_initials}"`
|
51
|
-
#puts"cmdout: " + cmd_git
|
52
|
-
else
|
53
|
-
#puts"in else"
|
54
|
-
#puts"git config user.name #{solo_author}"
|
55
|
-
#puts"git config user.email #{solo_email}"
|
56
|
-
`git config user.name "#{solo_author}"`
|
57
|
-
`git config user.email "#{solo_email}"`
|
58
|
-
`git config user.initials "#{solo_initials}"`
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
data/lib/commands/show.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
desc 'displays currently set pairing partners: $git pair show [-a | --all]'
|
2
|
-
command :show do |c|
|
3
|
-
c.desc 'list all available configured partners'
|
4
|
-
c.default_value false
|
5
|
-
c.switch :all, :a
|
6
|
-
|
7
|
-
c.action do |global_options,options,args|
|
8
|
-
# Check if we are in a git repo
|
9
|
-
unless system 'git status > /dev/null 2>/dev/null'
|
10
|
-
puts"Not in a git repo"
|
11
|
-
else
|
12
|
-
user = `git config --get user.name`.strip
|
13
|
-
email = `git config --get user.email`.strip
|
14
|
-
puts " "
|
15
|
-
puts "Git Config >"
|
16
|
-
puts "Name: #{user}"
|
17
|
-
puts "Email: #{email}"
|
18
|
-
end
|
19
|
-
# display list of configured partners
|
20
|
-
if options[:all]
|
21
|
-
puts " "
|
22
|
-
puts "Pairs Config >"
|
23
|
-
ap $pairs_conf
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
data/lib/commands/solo.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
desc 'resets git author to single global user: $git pair solo'
|
2
|
-
command :solo do |c|
|
3
|
-
c.action do |global_options,options,args|
|
4
|
-
`git config --unset-all user.name > /dev/null 2>/dev/null`
|
5
|
-
`git config --unset-all user.email > /dev/null 2>/dev/null`
|
6
|
-
`git config --unset-all user.initials > /dev/null 2>/dev/null`
|
7
|
-
`git config --remove-section user > /dev/null 2>/dev/null`
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
data/lib/git-pair.rb
DELETED
data/lib/pairs.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
module GitPairs
|
2
|
-
class Pairs
|
3
|
-
# Functions for manipulating the .pairs config file
|
4
|
-
def self.add(initials)
|
5
|
-
#if $pairs_conf["pairs"].include?(initials)
|
6
|
-
if self.exists?(initials)
|
7
|
-
puts"Pairing Partner '#{initials}' already exists"
|
8
|
-
else
|
9
|
-
#puts "In Add"
|
10
|
-
#ap $pairs_conf
|
11
|
-
unless GitPairs::Pairs.exists?(initials)
|
12
|
-
puts"Please provide info for: #{initials}"
|
13
|
-
name = ask("Full Name: ")
|
14
|
-
user = ask("Git Username: ")
|
15
|
-
#just in case they supply email address
|
16
|
-
user = user.split('@')[0]
|
17
|
-
email = ask("Email: ")
|
18
|
-
partner = {initials => {'name' => name, 'username' => user, 'email' => email}}
|
19
|
-
$pairs_conf["pairs"].update(partner)
|
20
|
-
temp_conf = YAML::Store.new(CFG_FILE)
|
21
|
-
temp_conf.transaction do
|
22
|
-
temp_conf["pairs"] = $pairs_conf["pairs"]
|
23
|
-
end
|
24
|
-
puts"Added '#{initials}' to list of available pairs"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.exists?(initials)
|
30
|
-
#puts "in exists?"
|
31
|
-
#ap $pairs_conf
|
32
|
-
#puts$pairs_conf["pairs"].include?(initials)
|
33
|
-
return $pairs_conf["pairs"].include?(initials)
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.fetch(initials)
|
37
|
-
return $pairs_conf["pairs"][initials]
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.delete(initials)
|
41
|
-
#puts "in delete"
|
42
|
-
#puts"before:"
|
43
|
-
#ap $pairs_conf
|
44
|
-
if $pairs_conf["pairs"].include?(initials)
|
45
|
-
$pairs_conf["pairs"].delete(initials)
|
46
|
-
temp_conf = YAML::Store.new(CFG_FILE)
|
47
|
-
temp_conf.transaction do
|
48
|
-
temp_conf["pairs"] = $pairs_conf["pairs"]
|
49
|
-
end
|
50
|
-
end
|
51
|
-
#puts"after:"
|
52
|
-
#ap $pairs_conf
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|