Class: GitIam::Iam
- Inherits:
-
Object
- Object
- GitIam::Iam
- Defined in:
- lib/git-iam/iam.rb
Class Method Summary collapse
- .local_or_remote(setting) ⇒ Object
- .remote_origin ⇒ Object
- .reset ⇒ Object
- .set_origin_account(account) ⇒ Object
- .set_user_config(args) ⇒ Object
- .set_user_email(user_email) ⇒ Object
- .set_user_name(user_name) ⇒ Object
- .user_email ⇒ Object
- .user_name ⇒ Object
- .who ⇒ Object
Class Method Details
.local_or_remote(setting) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/git-iam/iam.rb', line 23 def self.local_or_remote(setting) value = `git config --local #{setting}`.chomp if value.empty? value = `git config --global #{setting}`.chomp # + ' (global)' # interferes when reseting origin end value end |
.remote_origin ⇒ Object
19 20 21 |
# File 'lib/git-iam/iam.rb', line 19 def self.remote_origin local_or_remote 'remote.origin.url' end |
.reset ⇒ Object
58 59 60 61 62 |
# File 'lib/git-iam/iam.rb', line 58 def self.reset `git config --local --unset user.name` `git config --local --unset user.email` set_origin_account user_name end |
.set_origin_account(account) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/git-iam/iam.rb', line 49 def self.set_origin_account(account) segments = remote_origin.split('/') segments[-2] = account origin_url = segments.join('/') `git remote set-url origin #{origin_url}` end |
.set_user_config(args) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/git-iam/iam.rb', line 33 def self.set_user_config(args) user_name = args.shift user_email = args.shift self.set_user_name user_name self.set_user_email user_email unless user_email.nil? self.set_origin_account user_name end |
.set_user_email(user_email) ⇒ Object
45 46 47 |
# File 'lib/git-iam/iam.rb', line 45 def self.set_user_email(user_email) `git config --local user.email #{user_email}` end |
.set_user_name(user_name) ⇒ Object
41 42 43 |
# File 'lib/git-iam/iam.rb', line 41 def self.set_user_name(user_name) `git config --local user.name #{user_name}` end |
.user_email ⇒ Object
15 16 17 |
# File 'lib/git-iam/iam.rb', line 15 def self.user_email local_or_remote 'user.email' end |
.user_name ⇒ Object
11 12 13 |
# File 'lib/git-iam/iam.rb', line 11 def self.user_name local_or_remote 'user.name' end |
.who ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/git-iam/iam.rb', line 3 def self.who { 'user.name' => user_name, 'user.email' => user_email, 'remote.origin.url' => remote_origin } end |