Class: Git::Daily::Config
Constant Summary
collapse
- SUBCOMMAND =
{
"remote" => lambda {
r = remotes
r.map! {|url| url[/^remote\.([^\.]+)\.url=(.*)/, 1] }
selected_url = ARGV.shift
if r.find {|v| v == selected_url }
`git config gitdaily.remote #{selected_url}`
puts "Your remote is [#{selected_url}]"
else
raise "no such remote url: #{selected_url}"
end
},
"develop" => lambda {
b = branches
input = ARGV.shift
if b.find { |v| v == input }
`git config gitdaily.develop #{input}`
puts "Your development branch is [#{input}]"
else
raise "no such branch: #{input}"
end
},
"master" => lambda {
b = branches
input = ARGV.shift
if b.find { |v| v == input }
`git config gitdaily.master #{input}`
puts "Your master branch is [#{input}]"
else
raise "no such branch: #{input}"
end
},
"logurl" => lambda {
url = ARGV.shift
`git config gitdaily.logurl #{url}`
puts "Your log url is [#{url}]"
}
}
Instance Method Summary
collapse
Methods inherited from Command
branches, clean?, current_branch, develop, has_branch?, has_remote_branch?, #initialize, logurl, master, merged_branches, pull_request_url, release_branches, remote, remote_branch, remotes
Instance Method Details
#help ⇒ Object
46
47
48
|
# File 'lib/git-daily/command/config.rb', line 46
def help
"config\tSet or show config"
end
|
#run ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/git-daily/command/config.rb', line 50
def run
subcommand = ARGV.shift
if SUBCOMMAND.has_key?(subcommand)
return SUBCOMMAND[subcommand].call
end
r = `git config --list`.split(/\n/).select {|a| a[/^gitdaily/] }
if r.empty?
raise "git-daily: not initialized. please run: git daily init"
else
r.each do |s|
puts s
end
end
r
end
|
#usage ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/git-daily/command/config.rb', line 68
def usage
<<-EOS
Usage: git daily config remote origin
Example:
Remote name :
git daily config remote origin
Branch name of develop :
git daily config develop develop
Branch name of master :
git daily config master master
URL template for dump list (will dump commit hash instead of "%s") :
GitWeb : git daily config logurl "http://example.com/?p=repositories/example.git;a=commit;h=%s"
GitHub : git daily config logurl "https://github.com/sotarok/git-daily/commit/%s"
EOS
end
|