git-iam 0.0.3 → 0.0.4
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 +4 -4
- data/.gitignore +1 -0
- data/README.md +32 -26
- data/features/iam.feature +16 -3
- data/lib/git-iam/cli.rb +22 -23
- data/lib/git-iam/iam.rb +37 -47
- data/lib/git-iam/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 486931ce996602ce85db9bba9d6f8c8dce126f20
|
4
|
+
data.tar.gz: 73d50c12e31f18329c2cd1afdc60263e17f7efaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99a3da8634fec16454504f75f441c4053db962a79b20346475636f9e8d107d9d13c081a891faf7725eea98ee19b7eccd1de99dacbfcdb38a0b14e071358a0575
|
7
|
+
data.tar.gz: ea7df238219c43baa264048c5b8342981d9f2bb0e4c61d74014b6b0bdd1e7ca1b0885f2dfade38f945f2ad910572d173a85bc57deb61c0bfb54e513656de33f3
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,71 +1,77 @@
|
|
1
|
-
#
|
1
|
+
# git-iam
|
2
2
|
|
3
3
|
Command line tool for easily switching git authors, remotes, and other configs on shared computers.
|
4
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
5
|
## Installation
|
15
6
|
|
16
7
|
```
|
17
|
-
$ gem install
|
8
|
+
$ gem install git-iam
|
18
9
|
```
|
19
10
|
|
20
11
|
## Usage
|
21
12
|
|
22
|
-
Run via the command line using the command `iam`.
|
13
|
+
Run via the command line using the command `git iam`.
|
14
|
+
|
15
|
+
Set user name and remote origin url
|
16
|
+
|
17
|
+
```
|
18
|
+
$ git iam [USERNAME]
|
19
|
+
```
|
23
20
|
|
24
|
-
Set
|
21
|
+
Set user email along with name and remote origin url. (same as command above, optionally accepting an email address)
|
25
22
|
|
26
23
|
```
|
27
|
-
$ iam [
|
24
|
+
$ git iam [USERNAME] [EMAIL]
|
28
25
|
```
|
29
26
|
|
30
|
-
|
27
|
+
View current user name, email and remote origin url
|
31
28
|
|
32
29
|
```
|
33
|
-
$ iam who
|
30
|
+
$ git iam who
|
34
31
|
```
|
35
32
|
|
36
33
|
Reset to global git config values
|
37
34
|
|
38
35
|
```
|
39
|
-
$ iam reset
|
36
|
+
$ git iam reset
|
40
37
|
```
|
41
38
|
|
39
|
+
### Looking for a pairing solution?
|
40
|
+
|
41
|
+
`git-iam` works great with [git-pair](https://github.com/chrisk/git-pair). Easily set up a pair profile with `git-pair`, and then change config values with `git-iam`.
|
42
|
+
|
42
43
|
## Available commands
|
43
44
|
|
45
|
+
* `git iam [USERNAME]` Set user name and remote origin url.
|
46
|
+
* `git iam [USERNAME] [EMAIL]` Set user email along with name and remote origin url.
|
47
|
+
* `git iam who` View current user name, email and remote origin url.
|
48
|
+
* `git iam reset` Reset to global git config values.
|
49
|
+
* `git iam user [USERNAME]` Set user name.
|
50
|
+
* `git iam email [EMAIL]` Set user email.
|
51
|
+
|
44
52
|
Find all available commands
|
45
53
|
|
46
54
|
```
|
47
|
-
$ iam
|
55
|
+
$ git iam
|
48
56
|
```
|
49
57
|
|
50
58
|
Find details about a command
|
51
59
|
|
52
60
|
```
|
53
|
-
$ iam help [
|
61
|
+
$ git iam help [COMMAND]
|
54
62
|
```
|
55
63
|
|
56
64
|
## TODO
|
57
65
|
|
58
|
-
* Create pairing module - consider command `iam also [username]`
|
59
|
-
* Add
|
60
|
-
* Create helpers for changing options on remote urls `--branch`, `--remote`, etc.
|
61
|
-
* Create helper for viewing current configs.
|
66
|
+
* Create pairing module - consider command `git iam also [username]`
|
67
|
+
* Add a remote-only setting option `git iam [USERNAME] --remoteonly [REMOTEACOUNT]`, or `git iam remote [REMOTEACOUNT]`
|
68
|
+
* Create helpers for changing options on remote urls `--branch`, `--remote`, etc. (might overlap with previous bullet)
|
62
69
|
* 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.
|
70
|
+
* Implement a `--force` for `git iam [username]` incase the username conflicts with any reserved keywords.
|
65
71
|
|
66
72
|
## Contributing
|
67
73
|
|
68
|
-
1. Fork it
|
74
|
+
1. Fork it
|
69
75
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
70
76
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
71
77
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/features/iam.feature
CHANGED
@@ -7,12 +7,25 @@ Feature: Iam
|
|
7
7
|
When I run "git iam who"
|
8
8
|
Then the output should contain "user.name"
|
9
9
|
|
10
|
-
Scenario: Set current user
|
10
|
+
Scenario: Set current user config
|
11
11
|
When I run "git iam tyler"
|
12
12
|
Then the output should contain "tyler"
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
Scenario: Set user name only
|
15
|
+
When I run "git iam user tyleeeee"
|
16
|
+
Then the output should contain "tyleeeee"
|
17
|
+
|
18
|
+
Scenario: Set email only
|
19
|
+
When I run "git iam email tyler@co.co"
|
20
|
+
Then the output should contain "tyler@co.co"
|
21
|
+
|
22
|
+
Scenario: Set current user config, including email
|
23
|
+
When I run "git iam newTyler co@co.co"
|
24
|
+
Then the output should contain "newTyler"
|
25
|
+
Then the output should contain "co@co.co"
|
26
|
+
|
27
|
+
# not a great test
|
28
|
+
# largely used to reset git config after tests run
|
16
29
|
Scenario: Reset settings
|
17
30
|
When I run "git iam reset"
|
18
31
|
Then the output should contain "user.name"
|
data/lib/git-iam/cli.rb
CHANGED
@@ -6,45 +6,44 @@ module GitIam
|
|
6
6
|
|
7
7
|
desc "who", "Returns current user name and email from config."
|
8
8
|
def who
|
9
|
-
Helpers.
|
9
|
+
Helpers.print GitIam::Iam.who
|
10
10
|
end
|
11
11
|
|
12
12
|
desc "reset", "Reset the current local git settings to the global config."
|
13
13
|
def reset
|
14
|
-
|
14
|
+
GitIam::Iam.reset
|
15
|
+
who
|
15
16
|
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
desc "[USERNAME] [EMAIL]", "Set git user name and remote origin account. Optionally set git email address, if desired."
|
19
|
+
def set_user_config(args)
|
20
|
+
GitIam::Iam.set_user_config args
|
21
|
+
who
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "user [USERNAME]", "Set git user name."
|
25
|
+
def user(name)
|
26
|
+
GitIam::Iam.set_user_name name
|
27
|
+
who
|
28
|
+
end
|
23
29
|
|
24
|
-
desc "[
|
25
|
-
def
|
26
|
-
|
30
|
+
desc "email [EMAIL]", "Set git email address."
|
31
|
+
def email(email)
|
32
|
+
GitIam::Iam.set_user_email email
|
33
|
+
who
|
27
34
|
end
|
28
35
|
|
29
36
|
# allows user to be set without special flags
|
30
37
|
def method_missing(method, *args)
|
31
|
-
|
32
|
-
|
33
|
-
# args = [method.to_s] + args
|
34
|
-
|
35
|
-
set_user method.to_s
|
38
|
+
args.unshift(method.to_s)
|
39
|
+
set_user_config args
|
36
40
|
end
|
37
41
|
end
|
38
42
|
|
39
43
|
class Helpers
|
40
|
-
def self.
|
41
|
-
if statement.is_a?(Array)
|
42
|
-
return statement.each{ |s| pretty_print s }
|
43
|
-
end
|
44
|
-
|
44
|
+
def self.print(statement)
|
45
45
|
statement.each do |key, value|
|
46
|
-
|
47
|
-
print value + "\n"
|
46
|
+
puts "#{key}: #{value}"
|
48
47
|
end
|
49
48
|
end
|
50
49
|
end
|
data/lib/git-iam/iam.rb
CHANGED
@@ -1,53 +1,11 @@
|
|
1
|
-
MESSAGES = {
|
2
|
-
remote_origin: 'remote.origin.url',
|
3
|
-
user_name: 'user.name',
|
4
|
-
user_email: 'user.email'
|
5
|
-
}
|
6
|
-
|
7
1
|
module GitIam
|
8
2
|
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
3
|
def self.who
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
4
|
+
{
|
5
|
+
'user.name' => user_name,
|
6
|
+
'user.email' => user_email,
|
7
|
+
'remote.origin.url' => remote_origin
|
8
|
+
}
|
51
9
|
end
|
52
10
|
|
53
11
|
def self.user_name
|
@@ -71,5 +29,37 @@ module GitIam
|
|
71
29
|
|
72
30
|
value
|
73
31
|
end
|
32
|
+
|
33
|
+
def self.set_user_config(args)
|
34
|
+
user_name = args.shift
|
35
|
+
user_email = args.shift
|
36
|
+
self.set_user_name user_name
|
37
|
+
self.set_user_email user_email unless user_email.nil?
|
38
|
+
self.set_origin_account user_name
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.set_user_name(user_name)
|
42
|
+
`git config --local user.name #{user_name}`
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.set_user_email(user_email)
|
46
|
+
`git config --local user.email #{user_email}`
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.set_origin_account(account)
|
50
|
+
segments = remote_origin.split('/')
|
51
|
+
segments[-2] = account
|
52
|
+
|
53
|
+
origin_url = segments.join('/')
|
54
|
+
|
55
|
+
`git remote set-url origin #{origin_url}`
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.reset
|
59
|
+
`git config --local --unset user.name`
|
60
|
+
`git config --local --unset user.email`
|
61
|
+
set_origin_account user_name
|
62
|
+
end
|
63
|
+
|
74
64
|
end
|
75
65
|
end
|
data/lib/git-iam/version.rb
CHANGED