git-commit-autouser 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2670e53e5407a1820582f6843f45d7e4a2f9ab89
4
- data.tar.gz: 807765fc3f48b2349ffdb2ab90c36e36df294b41
3
+ metadata.gz: b55add773053e443181b209413e0b08017f8fb9a
4
+ data.tar.gz: a91a9f04c593d95eb96443b2c1234fc408e55ea3
5
5
  SHA512:
6
- metadata.gz: f1637e472970d91f41ede1a987f8c533816e7157663416feb41106bec0892d0cfbc0bdd88191a789d54a4da838540bac7583592315b3b7d29bae2a348459aa70
7
- data.tar.gz: 3e0887e341d7df8605d695e45f0eb318e3774e93df49c18111715bcea19761f8489e9ee4c002930cf35eb4fd2a6620a61961e7a6e8aeecbc39a90a8899b15a9e
6
+ metadata.gz: 6882c7a8307c22ab0fe4eae233d4ca1c3a7962de11624647a10bac747424c0c93ac8cde2445e05681e86d26564730a78e4a9b426b00c800b12ac2b4d181c8221
7
+ data.tar.gz: 1339aaa1fa061e332a5e534bdf11ad055a076350b7698397cb669fbad3317cd55a5888e059e331e5dfef4ea652d922a5af5758c7dad0e0a2f594f6a90e173080
@@ -1,38 +1,15 @@
1
1
  module GitCommitAutouser
2
2
  class Cli
3
3
  def self.start(argv=ARGV)
4
- abort_no_origin! unless Git.remote?("origin")
5
- remote_url = Git.remote_push_url("origin")
6
-
7
- users = Config.users
8
- abort_no_user_config! if users.empty?
9
-
10
- matched = nil
11
- users.each do |user|
12
- matched = user.url_regexp.match(remote_url)
13
- unless matched.nil?
14
- matched = user
15
- break
16
- end
4
+ unless Git.remote?("origin")
5
+ $stderr.puts "[warn] remote `origin` is not configured"
17
6
  end
18
7
 
19
- abort_no_user_matched! if matched.nil?
20
-
21
- env = {
22
- "GIT_COMMITTER_NAME" => matched.name,
23
- "GIT_COMMITTER_EMAIL" => matched.email,
24
- "GIT_AUTHOR_NAME" => matched.name,
25
- "GIT_AUTHOR_EMAIL" => matched.email,
26
- }
27
-
28
- env["HUB_CONFIG"] = matched.hub_config
29
-
30
- system env, "git", "commit", *argv
31
- exit $?.exitstatus
32
- end
8
+ remote_url = Git.remote_push_url("origin")
33
9
 
34
- def self.abort_no_user_config!
35
- $stderr.puts <<-EOS
10
+ users = Config.users
11
+ if users.empty?
12
+ $stderr.puts <<-EOS
36
13
  No user setting found. You should add to ~/.gitconfig like the following.
37
14
  ------
38
15
  [#{Config::USER_CONFIG_PREFIX}github]
@@ -44,19 +21,35 @@ No user setting found. You should add to ~/.gitconfig like the following.
44
21
  name = "Foo Bar"
45
22
  email = bar@company.com
46
23
  ------
47
- EOS
48
- exit 1
49
- end
24
+ EOS
25
+ abort
26
+ end
50
27
 
51
- def self.abort_no_origin!
52
- $stderr.puts "remote `origin` is not configured"
53
- exit 1
54
- end
28
+ matched = nil
29
+ users.each do |user|
30
+ matched = user.url_regexp.match(remote_url)
31
+ unless matched.nil?
32
+ matched = user
33
+ break
34
+ end
35
+ end
55
36
 
56
- def self.abort_no_user_matched!
57
- $stderr.puts "No user setting matched. Abort."
58
- $stderr.puts "Remote Url: #{remote_url}"
59
- exit 1
37
+ if matched
38
+ env = {
39
+ "GIT_COMMITTER_NAME" => matched.name,
40
+ "GIT_COMMITTER_EMAIL" => matched.email,
41
+ "GIT_AUTHOR_NAME" => matched.name,
42
+ "GIT_AUTHOR_EMAIL" => matched.email,
43
+ "HUB_CONFIG" => matched.hub_config,
44
+ }
45
+ else
46
+ env = {}
47
+ $stderr.puts "[warn] No user setting matched. Abort."
48
+ $stderr.puts "[warn] Remote Url: #{remote_url}"
49
+ end
50
+
51
+ system env, "git", "commit", *argv
52
+ exit $?.exitstatus
60
53
  end
61
54
  end
62
55
  end
@@ -1,3 +1,3 @@
1
1
  module GitCommitAutouser
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-commit-autouser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryota Arai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-01 00:00:00.000000000 Z
11
+ date: 2014-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler