git-iam 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/LICENSE.txt +22 -0
- data/README.md +72 -0
- data/Rakefile +1 -0
- data/bin/git-iam +3 -0
- data/features/iam.feature +18 -0
- data/git-iam.gemspec +40 -0
- data/lib/git-iam/cli.rb +51 -0
- data/lib/git-iam/iam.rb +75 -0
- data/lib/git-iam/version.rb +3 -0
- data/lib/git-iam.rb +6 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fa4f81429874fb8e7f81e81ae814493fe48b2132
|
4
|
+
data.tar.gz: 73a64286cedaaf7cb6b2e979bf4c5cc1f28f3920
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b2b53dbb1991e59c13963691ef141cacac5450db69c7925901d67f48a1a064841dfedccf17b209320fe3f5ab2985c68a8ae4ac0b0171cc2691221bd90ea27bc4
|
7
|
+
data.tar.gz: ab9dce3e88c803fe50533d8e1eee34b3d22125cb2cb62057d682d1345d3d4449ad0a737786e242a82e939b71404a032747cce09c6bad1a079c405cd62a07eed1
|
data/.gitignore
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 tgolson
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# git_iam
|
2
|
+
|
3
|
+
Command line tool for easily switching git authors, remotes, and other configs on shared computers.
|
4
|
+
|
5
|
+
**Currently in development**
|
6
|
+
|
7
|
+
References
|
8
|
+
|
9
|
+
* [Great ruby gem cli guide](https://github.com/radar/guides/blob/master/gem-development.md)
|
10
|
+
* [Nice ruby executable resource](http://robdodson.me/blog/2012/06/14/how-to-write-a-command-line-ruby-gem/)
|
11
|
+
* Major props to [git pair](https://github.com/chrisk/git-pair)
|
12
|
+
* Inspiration from [pivotal git scripts](https://github.com/pivotal/git_scripts)
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
```
|
17
|
+
$ gem install git_iam
|
18
|
+
```
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
Run via the command line using the command `iam`.
|
23
|
+
|
24
|
+
Set current user name and remote origin url
|
25
|
+
|
26
|
+
```
|
27
|
+
$ iam [user_name]
|
28
|
+
```
|
29
|
+
|
30
|
+
Check current user name, email and remote origin url
|
31
|
+
|
32
|
+
```
|
33
|
+
$ iam who
|
34
|
+
```
|
35
|
+
|
36
|
+
Reset to global git config values
|
37
|
+
|
38
|
+
```
|
39
|
+
$ iam reset
|
40
|
+
```
|
41
|
+
|
42
|
+
## Available commands
|
43
|
+
|
44
|
+
Find all available commands
|
45
|
+
|
46
|
+
```
|
47
|
+
$ iam
|
48
|
+
```
|
49
|
+
|
50
|
+
Find details about a command
|
51
|
+
|
52
|
+
```
|
53
|
+
$ iam help [command]
|
54
|
+
```
|
55
|
+
|
56
|
+
## TODO
|
57
|
+
|
58
|
+
* Create pairing module - consider command `iam also [username]`
|
59
|
+
* Add options to `iam [username]` commands, such as `--nameonly` or `--remoteonly`.
|
60
|
+
* Create helpers for changing options on remote urls `--branch`, `--remote`, etc.
|
61
|
+
* Create helper for viewing current configs.
|
62
|
+
* Consider integrating `git-pair` for pairing config.
|
63
|
+
* Implement a `--force` for `iam [username]` incase the username conflicts with any reserved keywords.
|
64
|
+
* Throw error if `remote.origin.url` not set.
|
65
|
+
|
66
|
+
## Contributing
|
67
|
+
|
68
|
+
1. Fork it ( git shttp://github.com/<my-github-username>/git_iam/fork )
|
69
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
70
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
71
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
72
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/git-iam
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Feature: Iam
|
2
|
+
In order to quickly change git settings
|
3
|
+
As a user
|
4
|
+
I want to have a clean interface
|
5
|
+
|
6
|
+
Scenario: Find out who I am
|
7
|
+
When I run "git iam who"
|
8
|
+
Then the output should contain "user.name"
|
9
|
+
|
10
|
+
Scenario: Set current user
|
11
|
+
When I run "git iam tyler"
|
12
|
+
Then the output should contain "tyler"
|
13
|
+
|
14
|
+
# Not a very good test
|
15
|
+
# Mainly used to reset previous test
|
16
|
+
Scenario: Reset settings
|
17
|
+
When I run "git iam reset"
|
18
|
+
Then the output should contain "user.name"
|
data/git-iam.gemspec
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'git-iam/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "git-iam"
|
8
|
+
spec.version = GitIam::VERSION
|
9
|
+
spec.authors = ["tgolson"]
|
10
|
+
spec.email = ["tydotg@gmail.com"]
|
11
|
+
spec.summary = %q{Command line tool for easily switching git authors, remotes, and other configs on shared computers.}
|
12
|
+
spec.description = %q{Command line tool for easily switching git authors, remotes, and other configs on shared computers.}
|
13
|
+
spec.homepage = "https://github.com/TGOlson/git_iam"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = [
|
17
|
+
".gitignore",
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.md",
|
20
|
+
"Rakefile",
|
21
|
+
"bin/git-iam",
|
22
|
+
"features/iam.feature",
|
23
|
+
"git-iam.gemspec",
|
24
|
+
"lib/git-iam.rb",
|
25
|
+
"lib/git-iam/version.rb",
|
26
|
+
"lib/git-iam/iam.rb",
|
27
|
+
"lib/git-iam/cli.rb"
|
28
|
+
]
|
29
|
+
|
30
|
+
spec.executables = ['git-iam']
|
31
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
32
|
+
spec.require_paths = ["lib"]
|
33
|
+
|
34
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
35
|
+
spec.add_development_dependency "rake"
|
36
|
+
spec.add_development_dependency "rspec", "~> 2.14"
|
37
|
+
spec.add_development_dependency "cucumber"
|
38
|
+
spec.add_development_dependency "aruba"
|
39
|
+
spec.add_dependency "thor"
|
40
|
+
end
|
data/lib/git-iam/cli.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'git-iam'
|
3
|
+
|
4
|
+
module GitIam
|
5
|
+
class CLI < Thor
|
6
|
+
|
7
|
+
desc "who", "Returns current user name and email from config."
|
8
|
+
def who
|
9
|
+
Helpers.pretty_print GitIam::Iam.who
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "reset", "Reset the current local git settings to the global config."
|
13
|
+
def reset
|
14
|
+
Helpers.pretty_print GitIam::Iam.reset
|
15
|
+
end
|
16
|
+
|
17
|
+
# Not implemented
|
18
|
+
# Will later be used for pairing
|
19
|
+
# desc "aka [USERNAME]", "Sets current user name and remote account name."
|
20
|
+
# def aka(user_name)
|
21
|
+
# Helpers.pretty_print GitIam::Iam.set_user_name(user_name)
|
22
|
+
# end
|
23
|
+
|
24
|
+
desc "[USERNAME]", "Sets current user name and remote origin account."
|
25
|
+
def set_user(user, *args)
|
26
|
+
Helpers.pretty_print GitIam::Iam.set_user(user)
|
27
|
+
end
|
28
|
+
|
29
|
+
# allows user to be set without special flags
|
30
|
+
def method_missing(method, *args)
|
31
|
+
# might be useful for taking in more information with default iam
|
32
|
+
# such as email
|
33
|
+
# args = [method.to_s] + args
|
34
|
+
|
35
|
+
set_user method.to_s
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class Helpers
|
40
|
+
def self.pretty_print(statement)
|
41
|
+
if statement.is_a?(Array)
|
42
|
+
return statement.each{ |s| pretty_print s }
|
43
|
+
end
|
44
|
+
|
45
|
+
statement.each do |key, value|
|
46
|
+
print key.ljust(20)
|
47
|
+
print value + "\n"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/git-iam/iam.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
MESSAGES = {
|
2
|
+
remote_origin: 'remote.origin.url',
|
3
|
+
user_name: 'user.name',
|
4
|
+
user_email: 'user.email'
|
5
|
+
}
|
6
|
+
|
7
|
+
module GitIam
|
8
|
+
class Iam
|
9
|
+
|
10
|
+
def self.set_user(user)
|
11
|
+
self.set_user_name(user)
|
12
|
+
# self.set_user_email
|
13
|
+
self.set_origin_account(user)
|
14
|
+
who
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.set_user_name(user_name)
|
18
|
+
`git config --local user.name #{user_name}`
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.set_user_email
|
22
|
+
# TODO - implement setting user email
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.set_origin_account(account)
|
26
|
+
segments = remote_origin.split('/')
|
27
|
+
segments[-2] = account
|
28
|
+
|
29
|
+
origin_url = segments.join('/')
|
30
|
+
|
31
|
+
`git remote set-url origin #{origin_url}`
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.who
|
35
|
+
[
|
36
|
+
msg(:user_name, user_name),
|
37
|
+
msg(:user_email, user_email),
|
38
|
+
msg(:remote_origin, remote_origin)
|
39
|
+
]
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.msg(key, value)
|
43
|
+
{ MESSAGES[key] => value }
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.reset
|
47
|
+
`git config --local --unset user.name`
|
48
|
+
`git config --local --unset user.email`
|
49
|
+
set_origin_account user_name
|
50
|
+
who
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.user_name
|
54
|
+
local_or_remote 'user.name'
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.user_email
|
58
|
+
local_or_remote 'user.email'
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.remote_origin
|
62
|
+
local_or_remote 'remote.origin.url'
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.local_or_remote(setting)
|
66
|
+
value = `git config --local #{setting}`.chomp
|
67
|
+
|
68
|
+
if value.empty?
|
69
|
+
value = `git config --global #{setting}`.chomp # + ' (global)' # interferes when reseting origin
|
70
|
+
end
|
71
|
+
|
72
|
+
value
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/lib/git-iam.rb
ADDED
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: git-iam
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- tgolson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
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: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.14'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.14'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: cucumber
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: aruba
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: thor
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Command line tool for easily switching git authors, remotes, and other
|
98
|
+
configs on shared computers.
|
99
|
+
email:
|
100
|
+
- tydotg@gmail.com
|
101
|
+
executables:
|
102
|
+
- git-iam
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- ".gitignore"
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- bin/git-iam
|
111
|
+
- features/iam.feature
|
112
|
+
- git-iam.gemspec
|
113
|
+
- lib/git-iam.rb
|
114
|
+
- lib/git-iam/cli.rb
|
115
|
+
- lib/git-iam/iam.rb
|
116
|
+
- lib/git-iam/version.rb
|
117
|
+
homepage: https://github.com/TGOlson/git_iam
|
118
|
+
licenses:
|
119
|
+
- MIT
|
120
|
+
metadata: {}
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
requirements: []
|
136
|
+
rubyforge_project:
|
137
|
+
rubygems_version: 2.2.2
|
138
|
+
signing_key:
|
139
|
+
specification_version: 4
|
140
|
+
summary: Command line tool for easily switching git authors, remotes, and other configs
|
141
|
+
on shared computers.
|
142
|
+
test_files:
|
143
|
+
- features/iam.feature
|