git-pairing 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/bin/git-pair +80 -0
- data/lib/commands/add.rb +20 -0
- data/lib/commands/rm.rb +17 -0
- data/lib/commands/set.rb +64 -0
- data/lib/commands/show.rb +27 -0
- data/lib/commands/solo.rb +10 -0
- data/lib/git-pair.rb +7 -0
- data/lib/pairs.rb +55 -0
- metadata +107 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MzAxNDUxZTQ2OTlhOGMzNGFiMWVjMDg0NWE4NTE4YTBjYzU1MWMxOQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NWE2MmEwNmZiNjJjZGFjMjFmODY3YTg3YzZjM2NmNjBmZGNiNjdhYQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZTQyYzhmMzI1NWQ2YWIyM2VlMDlhNThkZGEwNGNiZDViMTFiMjlkZGU2YzQ0
|
10
|
+
MzgzNDVlZjk1N2VlZDAxMGEzOGUyM2NjMTRlMDY0YTEwNTQyNDk2YzJkMjE5
|
11
|
+
ZDcwOTI4MjZmN2YyZDVlNzM5NTEwY2M1ZGUwN2ZmYjg2MTllMzA=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZTRjNmY3NDM5MGU4ZjEwZDM5NjYwM2JiZWQxMGJlNTg4MDIyMWM5ZjY1NjJm
|
14
|
+
MjI5YzkzNDljOGQzYmYxNzhkYTA1NGU2MmYwMDY5ZDM1YzQzMjVjOTBjYWNl
|
15
|
+
Mjk1M2Y5MjQ4NzllYzM4ZDg2YWRlMTRiNTFhY2I2YzQwZWY0OTE=
|
data/bin/git-pair
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
=begin
|
4
|
+
# 1.9 adds realpath to resolve symlinks; 1.8 doesn't
|
5
|
+
# have this method, so we add it so we get resolved symlinks
|
6
|
+
# and compatibility
|
7
|
+
unless File.respond_to? :realpath
|
8
|
+
class File #:nodoc:
|
9
|
+
def self.realpath path
|
10
|
+
return realpath(File.readlink(path)) if symlink?(path)
|
11
|
+
path
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
$: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
|
17
|
+
#$: << File.expand_path(File.dirname(__FILE__) + './../lib')
|
18
|
+
=end
|
19
|
+
|
20
|
+
require 'gli'
|
21
|
+
require 'git-pair'
|
22
|
+
|
23
|
+
include GLI::App
|
24
|
+
|
25
|
+
program_desc 'Keeps track of co-authors of git commits'
|
26
|
+
preserve_argv
|
27
|
+
wrap_help_text :verbatim
|
28
|
+
|
29
|
+
# config file is put into the user's home directory
|
30
|
+
CFG_FILE = File.join(File.expand_path(ENV['HOME']),'.pairs')
|
31
|
+
|
32
|
+
pre do |global,command,options,args|
|
33
|
+
# Pre logic here
|
34
|
+
# Return true to proceed; false to abort and not call the chosen command
|
35
|
+
# Use skips_pre before a command to skip this block
|
36
|
+
# on that command only
|
37
|
+
|
38
|
+
# Create config if it doesn't already exist
|
39
|
+
unless File.exists?(CFG_FILE)
|
40
|
+
name = `git config --global --get user.name`
|
41
|
+
initials = ""
|
42
|
+
name.strip.downcase.split(/ /).each { |n| initials << n.split(//)[0] }
|
43
|
+
email = `git config --get user.email`
|
44
|
+
username = email.split("@")[0]
|
45
|
+
$pairs_conf = YAML::Store.new(CFG_FILE)
|
46
|
+
$pairs_conf.transaction do
|
47
|
+
$pairs_conf["pairs"] = {"#{initials}" => {'name'=>"#{name.strip}", 'username'=>"#{username}", 'email'=>"#{email.strip}"} }
|
48
|
+
#puts "in conf create"
|
49
|
+
#ap $pairs_conf
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Load .pairs config
|
54
|
+
if (File.exist?(CFG_FILE))
|
55
|
+
$pairs_conf = YAML::load(File.open(CFG_FILE, 'r'))
|
56
|
+
#puts "in conf load"
|
57
|
+
#ap $pairs_conf
|
58
|
+
else
|
59
|
+
exit_now!("No ~/.pairs config file found")
|
60
|
+
end
|
61
|
+
|
62
|
+
true
|
63
|
+
end
|
64
|
+
|
65
|
+
post do |global,command,options,args|
|
66
|
+
# Post logic here
|
67
|
+
# Use skips_post before a command to skip this
|
68
|
+
# block on that command only
|
69
|
+
end
|
70
|
+
|
71
|
+
on_error do |exception|
|
72
|
+
# Error logic here
|
73
|
+
# return false to skip default error handling
|
74
|
+
true
|
75
|
+
end
|
76
|
+
|
77
|
+
# put command rb files into ./lib/commands/
|
78
|
+
commands_from './../lib/commands'
|
79
|
+
|
80
|
+
exit run(ARGV)
|
data/lib/commands/add.rb
ADDED
@@ -0,0 +1,20 @@
|
|
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
ADDED
@@ -0,0 +1,17 @@
|
|
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
ADDED
@@ -0,0 +1,64 @@
|
|
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 << " "
|
45
|
+
sorted_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
|
+
|
@@ -0,0 +1,27 @@
|
|
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
|
+
|
@@ -0,0 +1,10 @@
|
|
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`
|
5
|
+
`git config --unset-all user.email`
|
6
|
+
`git config --unset-all user.initials`
|
7
|
+
`git config --remove-section user`
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
data/lib/git-pair.rb
ADDED
data/lib/pairs.rb
ADDED
@@ -0,0 +1,55 @@
|
|
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
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: git-pairing
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Steve Quince
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-04-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: awesome_print
|
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: highline
|
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'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: gli
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.5.4
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.5.4
|
69
|
+
description: Keeps track of co-authors of git commits
|
70
|
+
email: steve.quince@gmail.com
|
71
|
+
executables: []
|
72
|
+
extensions: []
|
73
|
+
extra_rdoc_files: []
|
74
|
+
files:
|
75
|
+
- bin/git-pair
|
76
|
+
- lib/commands/add.rb
|
77
|
+
- lib/commands/rm.rb
|
78
|
+
- lib/commands/set.rb
|
79
|
+
- lib/commands/show.rb
|
80
|
+
- lib/commands/solo.rb
|
81
|
+
- lib/git-pair.rb
|
82
|
+
- lib/pairs.rb
|
83
|
+
homepage: https://github.com/squince/git-pairing
|
84
|
+
licenses: []
|
85
|
+
metadata: {}
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.0.2
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: Configures git to attribute code commits to multiple authors.
|
107
|
+
test_files: []
|