3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/git_commit_autouser/cli.rb', line 3
def self.start(argv=ARGV)
unless Git.remote?("origin")
$stderr.puts "[warn] remote `origin` is not configured"
end
remote_url = Git.remote_push_url("origin")
users = Config.users
if users.empty?
$stderr.puts "No user setting found. You should add to ~/.gitconfig like the following.\n------\n[\#{Config::USER_CONFIG_PREFIX}github]\n url-regexp = github.com\n name = \"Foo Bar\"\n email = [email protected]\n[\#{Config::USER_CONFIG_PREFIX}ghe]\n url-regexp = git.company.com\n name = \"Foo Bar\"\n email = [email protected]\n------\n EOS\n abort\n end\n\n matched = nil\n users.each do |user|\n matched = user.url_regexp.match(remote_url)\n unless matched.nil?\n matched = user\n break\n end\n end\n\n if matched\n env = {\n \"GIT_COMMITTER_NAME\" => matched.name,\n \"GIT_COMMITTER_EMAIL\" => matched.email,\n \"GIT_AUTHOR_NAME\" => matched.name,\n \"GIT_AUTHOR_EMAIL\" => matched.email,\n \"HUB_CONFIG\" => matched.hub_config,\n }\n else\n env = {}\n $stderr.puts \"[warn] No user setting matched. Abort.\"\n $stderr.puts \"[warn] Remote Url: \#{remote_url}\"\n end\n\n system env, \"git\", \"commit\", *argv\n exit $?.exitstatus\nend\n"
|