lib/grb.rb in jinzhu-grb-0.0.1 vs lib/grb.rb in jinzhu-grb-0.1.0
- old
+ new
@@ -2,32 +2,32 @@
GIT = ENV['GRB_GIT'] || 'git'
ORIGIN = ENV['GRB_ORIGIN'] || 'origin'
COMMANDS = {
:new => {
- :desc => "grb new [branch]",
+ :desc => "=> create new branch `branch`\ngrb new [branch] [--explain]",
:commands => [
'"#{GIT} push #{origin} #{current_branch}:refs/heads/#{branch}"',
'"#{GIT} fetch #{origin}"',
'"#{GIT} branch --track #{branch} #{origin}/#{branch}"',
'"#{GIT} checkout #{branch}"'
]
},
:push => {
- :desc => "grb push [branch] (default current_branch)",
+ :desc => "=> push branch `branch`, default current_branch\ngrb push [branch] [--explain]",
:commands => [
'"#{GIT} push #{origin} #{branch}:refs/heads/#{branch}"',
'"#{GIT} fetch #{origin}"',
'"#{GIT} config branch.#{branch}.remote #{origin}"',
'"#{GIT} config branch.#{branch}.merge refs/heads/#{branch}"',
'"#{GIT} checkout #{branch}"'
]
},
:mv => {
- :desc => "grb mv [branch1] [branch2]\n\tgrb mv [branch] (default current_branch)",
+ :desc => "=> rename `branch1` to `branch2`\ngrb mv [branch1] [branch2] [--explain]\n=> rename current branch to `branch`\ngrb mv branch [--explain]",
:commands => [
' if(branch != branch_)
"#{GIT} push #{origin} #{branch}:refs/heads/#{branch_}
#{GIT} fetch #{origin}
#{GIT} branch --track #{branch_} #{origin}/#{branch_}
@@ -44,20 +44,20 @@
end'
]
},
:rm => {
- :desc => "grb rm [branch] (default current_branch)",
+ :desc => "=> delete branch `branch`,default current_branch\ngrb rm [branch] [--explain]",
:commands => [
'"#{GIT} push #{origin} :refs/heads/#{branch}"',
'"#{GIT} checkout master" if current_branch == branch',
'"#{GIT} branch -d #{branch}"'
]
},
:pull => {
- :desc => "grb pull [branch] (default current_branch)",
+ :desc => "=> pull branch `branch`,default current_branch\ngrb pull [branch] [--explain]",
:commands => [
'"#{GIT} fetch #{origin}"',
'if local_branches.include?(branch)
"#{GIT} config branch.#{branch}.remote #{origin}\n" +
"#{GIT} config branch.#{branch}.merge refs/heads/#{branch}"
@@ -79,11 +79,11 @@
end
def self.exec_cmd(str)
return true unless str
puts("\e[031m" + str.gsub(/^\s*/,'') + "\e[0m")
- system("#{str}")
+ system("#{str}") unless EXPLAIN
end
def self.get_current_branch
(`git branch 2> /dev/null | grep '^\*'`).gsub(/\W/,'')
end
@@ -92,8 +92,8 @@
(`git branch -l`).split(/\n/).map{|x| x.gsub(/\W/,'')}
end
def self.help(*args)
puts "USAGE:"
- COMMANDS.values.map {|x| puts "\t" + x[:desc]}
+ COMMANDS.values.map {|x| puts x[:desc].gsub(/^(\W.*)$/,"\e[31m" + '\1' + "\e[0m").gsub(/^(\w.*)$/,' $ \1')}
end
end