pivotal_git_scripts 1.1.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.
- data/.gitignore +3 -0
- data/MIT.LICENSE +20 -0
- data/README.md +46 -0
- data/Rakefile +2 -0
- data/bin/git-about +18 -0
- data/bin/git-pair +113 -0
- data/bin/git-project +35 -0
- data/bin/git-superpull +2 -0
- data/pivotal_git_scripts.gemspec +17 -0
- metadata +79 -0
data/.gitignore
ADDED
data/MIT.LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Pivotal Labs
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Git Scripts
|
2
|
+
|
3
|
+
These scripts are helpers for managing developer workflow when using git repos hosted on GitHub. Install as a rubygem and they can be run as standard git commands like `git about`.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install pivotal_git_scripts
|
8
|
+
|
9
|
+
## git-about
|
10
|
+
|
11
|
+
`git about` shows settings set by `git pair` and `git project`
|
12
|
+
|
13
|
+
## git-pair
|
14
|
+
|
15
|
+
$ git pair js sp
|
16
|
+
user.name=Josh Susser & Sam Pierson
|
17
|
+
user.email=pair+jsusser+sam@pivotallabs.com
|
18
|
+
|
19
|
+
|
20
|
+
Use `git pair` to set the git config user info that sets the commit user metadata. You'll need to create a `.pairs` config file to map initials to names and email ids. The example file:
|
21
|
+
|
22
|
+
# .pairs - configuration for 'git pair'
|
23
|
+
# place in project or home directory
|
24
|
+
pairs:
|
25
|
+
eh: Edward Hieatt
|
26
|
+
js: Josh Susser; jsusser
|
27
|
+
sf: Serguei Filimonov; serguei
|
28
|
+
email:
|
29
|
+
prefix: pair
|
30
|
+
domain: pivotallabs.com
|
31
|
+
|
32
|
+
You can put the .pairs file in your project repo root directory and check it into git, or you can put it in your ~ directory so it's available to all projects on the workstation.
|
33
|
+
|
34
|
+
By default this command affects the configuration in the current project (.git/config). Use the `--global` option to set the global git configuration for all projects (~/.gitconfig).
|
35
|
+
|
36
|
+
## git-project
|
37
|
+
|
38
|
+
$ git project pivots
|
39
|
+
|
40
|
+
This script sets the user account you will use to access repos hosted on github.com. It creates a symlink from `id_github_current` to `id_github_pivotal<project>`, which switches the SSH key you are currently using to access GitHub repos. Make sure you have the following lines in your .ssh/config file:
|
41
|
+
|
42
|
+
Host github.com
|
43
|
+
User git
|
44
|
+
IdentityFile /Users/pivotal/.ssh/id_github_current
|
45
|
+
|
46
|
+
Copyright (c) 2010 Pivotal Labs. This software is licensed under the MIT License.
|
data/Rakefile
ADDED
data/bin/git-about
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
config = `git config -l`
|
4
|
+
user_name = `git config --get user.name`
|
5
|
+
user_name = "NONE" if user_name.length == 0
|
6
|
+
user_email = `git config --get user.email`
|
7
|
+
user_email = "NONE" if user_email.length == 0
|
8
|
+
|
9
|
+
begin
|
10
|
+
keyfile = File.readlink(File.expand_path("~/.ssh/id_github_current"))
|
11
|
+
project = keyfile =~ %r{id_github_(\w+)} ? $1 : "NONE"
|
12
|
+
rescue Errno::ENOENT
|
13
|
+
project = "NONE"
|
14
|
+
end
|
15
|
+
|
16
|
+
puts "git user: #{user_name}"
|
17
|
+
puts "git email: #{user_email}"
|
18
|
+
puts "GitHub project: #{project}"
|
data/bin/git-pair
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Configures the git author to a list of developers when pair programming,
|
4
|
+
# alphabetized on first name
|
5
|
+
#
|
6
|
+
# Usage: git pair ls gw (Sets the repo specific author to 'Greg Woodward & Loren Siebert')
|
7
|
+
# git pair (Unsets the repo specific author so the git global config takes effect)
|
8
|
+
# git pair --global ls gw (Sets the global author to 'Greg Woodward & Loren Siebert')
|
9
|
+
# git pair --global (Unsets the global author)
|
10
|
+
#
|
11
|
+
# Orginal Author: Bryan Helmkamp (http://brynary.com)
|
12
|
+
|
13
|
+
#######################################################################
|
14
|
+
|
15
|
+
require 'yaml'
|
16
|
+
|
17
|
+
unless File.exists?(".git")
|
18
|
+
puts "This doesn't look like a git repository."
|
19
|
+
exit 1
|
20
|
+
end
|
21
|
+
|
22
|
+
## Configuration
|
23
|
+
|
24
|
+
def get_pairs_config
|
25
|
+
pairs_file_path = nil
|
26
|
+
candidate_file_path = '.pairs'
|
27
|
+
until pairs_file_path || File.expand_path(candidate_file_path) == '/.pairs' do
|
28
|
+
if File.exists?(candidate_file_path)
|
29
|
+
pairs_file_path = candidate_file_path
|
30
|
+
else
|
31
|
+
candidate_file_path = File.join("..", candidate_file_path)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
unless pairs_file_path
|
35
|
+
puts <<-INSTRUCTIONS
|
36
|
+
Could not find a .pairs file. Create a YAML file in your project or home directory.
|
37
|
+
Format: <initials>: <name>[; <email>]
|
38
|
+
Example:
|
39
|
+
# .pairs - configuration for 'git pair'
|
40
|
+
# place in project or home directory
|
41
|
+
pairs:
|
42
|
+
eh: Edward Hieatt
|
43
|
+
js: Josh Susser; jsusser
|
44
|
+
sf: Serguei Filimonov; serguei
|
45
|
+
email:
|
46
|
+
prefix: pair
|
47
|
+
domain: pivotallabs.com
|
48
|
+
INSTRUCTIONS
|
49
|
+
exit(1)
|
50
|
+
end
|
51
|
+
pairs_file_path ? YAML.load_file(pairs_file_path) : {}
|
52
|
+
end
|
53
|
+
|
54
|
+
## End of configuration
|
55
|
+
#######################################################################
|
56
|
+
|
57
|
+
global_config_string = ARGV.delete("--global").to_s
|
58
|
+
config = get_pairs_config
|
59
|
+
authors = ARGV.map do |initials|
|
60
|
+
if full_name = config['pairs'][initials.downcase]
|
61
|
+
full_name
|
62
|
+
else
|
63
|
+
puts "Couldn't find author name for initials: #{initials}. Add this person to the .pairs file in your project or home directory."
|
64
|
+
exit 1
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
if authors.any?
|
69
|
+
authors.sort!.uniq!
|
70
|
+
names, emails = authors.collect do |a|
|
71
|
+
both = a.split(";").collect {|s| s.strip}
|
72
|
+
both << both[0].split(' ').first.downcase if both.length == 1 # default email to first name
|
73
|
+
both
|
74
|
+
end.transpose
|
75
|
+
|
76
|
+
case authors.size
|
77
|
+
when 1
|
78
|
+
authors = names.first
|
79
|
+
when 2
|
80
|
+
authors = names.join(" & ")
|
81
|
+
else
|
82
|
+
authors = names[0..-2].join(", ") + " & " + names.last
|
83
|
+
end
|
84
|
+
email =
|
85
|
+
if email_prefix = config['email']['prefix']
|
86
|
+
"#{([email_prefix] + emails).join('+')}@#{config['email']['domain']}"
|
87
|
+
else
|
88
|
+
config['email']
|
89
|
+
end
|
90
|
+
system(%Q{git config #{global_config_string} user.name "#{authors}"})
|
91
|
+
system(%Q{git config #{global_config_string} user.email "#{email}"})
|
92
|
+
else
|
93
|
+
system("git config #{global_config_string} --unset user.name")
|
94
|
+
system("git config #{global_config_string} --unset user.email")
|
95
|
+
puts "Unset #{global_config_string} user.name and user.email"
|
96
|
+
end
|
97
|
+
|
98
|
+
global_name_setting = `git config --global --get-regexp '^user\.name'`
|
99
|
+
local_name_setting = `git config -f .git/config --get-regexp '^user\.name'`
|
100
|
+
if global_name_setting.length > 0 && local_name_setting.length > 0
|
101
|
+
puts "NOTE: Overriding global user.name setting with local."
|
102
|
+
end
|
103
|
+
puts "global: #{global_name_setting}" if global_name_setting.length > 0
|
104
|
+
puts "local: #{local_name_setting}" if local_name_setting.length > 0
|
105
|
+
|
106
|
+
|
107
|
+
global_email_setting = `git config --global --get-regexp '^user\.email'`
|
108
|
+
local_email_setting = `git config -f .git/config --get-regexp '^user\.email'`
|
109
|
+
if global_email_setting.length > 0 && local_email_setting.length > 0
|
110
|
+
puts "NOTE: Overriding global user.email setting with local."
|
111
|
+
end
|
112
|
+
puts "global: #{global_email_setting}" if global_email_setting.length > 0
|
113
|
+
puts "local: #{local_email_setting}" if local_email_setting.length > 0
|
data/bin/git-project
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'socket'
|
3
|
+
|
4
|
+
def check_ssh_config
|
5
|
+
if `grep -c id_github_current config`.to_i == 0
|
6
|
+
puts <<-WARNING
|
7
|
+
You must edit your .ssh/config file to include:
|
8
|
+
Host github.com
|
9
|
+
User git
|
10
|
+
IdentityFile /Users/pivotal/.ssh/id_github_current
|
11
|
+
WARNING
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
project = ARGV[0] || Dir.pwd.split('/').last
|
16
|
+
hostname = Socket.gethostname.split('.').first
|
17
|
+
possible_id_files = [
|
18
|
+
"id_#{hostname}_github_pivotal#{project}",
|
19
|
+
"id_github_pivotal#{project}",
|
20
|
+
"id_github_#{project}"
|
21
|
+
]
|
22
|
+
|
23
|
+
Dir.chdir(File.expand_path('~/.ssh')) do
|
24
|
+
possible_id_files.each do |id_file|
|
25
|
+
if File.exists?(id_file)
|
26
|
+
`ln -sf #{id_file} id_github_current`
|
27
|
+
puts "Now using key #{id_file}"
|
28
|
+
check_ssh_config
|
29
|
+
exit 0
|
30
|
+
end
|
31
|
+
end
|
32
|
+
puts "Key not found. You must create a ssh key in ~/.ssh/ called " +
|
33
|
+
possible_id_files[0..-2].join(", ") +
|
34
|
+
" or #{possible_id_files[-1]}"
|
35
|
+
end
|
data/bin/git-superpull
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "pivotal_git_scripts"
|
5
|
+
s.version = "1.1.0"
|
6
|
+
s.date = Time.now.strftime('%Y-%m-%d')
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["Pivotal Labs"]
|
9
|
+
s.email = ["gems@pivotallabs.com"]
|
10
|
+
s.homepage = "http://github.com/pivotal/git_scripts"
|
11
|
+
s.summary = %q{Developer git workflow convenience scripts}
|
12
|
+
s.description = %q{These scripts are helpers for managing developer workflow when using git repos hosted on GitHub.}
|
13
|
+
s.has_rdoc = false
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pivotal_git_scripts
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 19
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 1.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Pivotal Labs
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-11-15 00:00:00 -08:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: These scripts are helpers for managing developer workflow when using git repos hosted on GitHub.
|
23
|
+
email:
|
24
|
+
- gems@pivotallabs.com
|
25
|
+
executables:
|
26
|
+
- git-about
|
27
|
+
- git-pair
|
28
|
+
- git-project
|
29
|
+
- git-superpull
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files: []
|
33
|
+
|
34
|
+
files:
|
35
|
+
- .gitignore
|
36
|
+
- MIT.LICENSE
|
37
|
+
- README.md
|
38
|
+
- Rakefile
|
39
|
+
- bin/git-about
|
40
|
+
- bin/git-pair
|
41
|
+
- bin/git-project
|
42
|
+
- bin/git-superpull
|
43
|
+
- pivotal_git_scripts.gemspec
|
44
|
+
has_rdoc: true
|
45
|
+
homepage: http://github.com/pivotal/git_scripts
|
46
|
+
licenses: []
|
47
|
+
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 3
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
hash: 3
|
68
|
+
segments:
|
69
|
+
- 0
|
70
|
+
version: "0"
|
71
|
+
requirements: []
|
72
|
+
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 1.3.7
|
75
|
+
signing_key:
|
76
|
+
specification_version: 3
|
77
|
+
summary: Developer git workflow convenience scripts
|
78
|
+
test_files: []
|
79
|
+
|