grb 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +24 -0
- data/TODO +14 -0
- data/VERSION +1 -0
- data/bin/grb +5 -6
- metadata +22 -26
- data/Manifest +0 -5
- data/Rakefile +0 -14
- data/grb.gemspec +0 -32
- data/lib/grb.rb +0 -125
- data/lib/version.rb +0 -3
data/README.rdoc
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
= GRB
|
2
|
+
re-implement git_remote_branch [http://github.com/webmat/git_remote_branch] for cleaner,simpler,stronger!
|
3
|
+
|
4
|
+
== Install:
|
5
|
+
$ sudo gem install jinzhu-grb
|
6
|
+
|
7
|
+
== USAGE:
|
8
|
+
* rename `branch1` to `branch2`
|
9
|
+
$ grb mv [branch1] [branch2] [--explain]
|
10
|
+
* rename current branch to `branch`
|
11
|
+
$ grb mv branch [--explain]
|
12
|
+
* delete branch `branch`,default current_branch
|
13
|
+
$ grb rm [branch] [--explain]
|
14
|
+
* pull branch `branch`,default current_branch
|
15
|
+
$ grb pull [branch] [--explain]
|
16
|
+
* push branch `branch`, default current_branch
|
17
|
+
$ grb push [branch] [--explain]
|
18
|
+
* create new branch `branch`
|
19
|
+
$ grb new [branch] [--explain]
|
20
|
+
|
21
|
+
Copyright (c) 2009-present GPL3
|
22
|
+
|
23
|
+
Author : Jinzhu Zhang
|
24
|
+
Email : wosmvp@gmail.com
|
data/TODO
ADDED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.3.1
|
data/bin/grb
CHANGED
@@ -1,27 +1,26 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
#
|
3
|
-
# Copyright (c) 2009. GPL3.
|
3
|
+
# Copyright (c) 2009-present. GPL3.
|
4
4
|
# Author: Zhang Jinzhu
|
5
5
|
|
6
6
|
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
|
7
|
+
require "grb"
|
7
8
|
|
8
|
-
# easy
|
9
|
+
# easy debugger
|
9
10
|
if ARGV.delete('--debug')
|
10
11
|
['rubygems','ruby-debug'].each {|x| require x}
|
11
12
|
else
|
12
13
|
def debugger;end
|
13
14
|
end
|
14
15
|
|
15
|
-
require "version"
|
16
|
-
require "grb"
|
17
16
|
|
18
|
-
abort('Version: ' +
|
17
|
+
abort('Version: ' + File.read(File.expand_path("../../VERSION",__FILE__))) if ARGV.delete('--version') || ARGV.delete('-v')
|
19
18
|
|
20
19
|
EXPLAIN = ARGV.delete('--explain') || ARGV.delete('-e')
|
21
20
|
|
22
21
|
opt = {
|
23
22
|
:command => ARGV[0] || 'push',
|
24
|
-
:branch
|
23
|
+
:branch => branch = (ARGV[1] || Grb.get_current_branch),
|
25
24
|
:branch_ => ARGV[2] || branch,
|
26
25
|
}
|
27
26
|
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 17
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
9
|
+
- 1
|
10
|
+
version: 0.3.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Jinzhu Zhang
|
@@ -14,62 +15,57 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
-
default_executable:
|
18
|
+
date: 2010-07-19 00:00:00 +08:00
|
19
|
+
default_executable: grb
|
19
20
|
dependencies: []
|
20
21
|
|
21
|
-
description:
|
22
|
+
description: A tool to simplify working with remote branches
|
22
23
|
email: wosmvp@gmail.com
|
23
24
|
executables:
|
24
25
|
- grb
|
25
26
|
extensions: []
|
26
27
|
|
27
28
|
extra_rdoc_files:
|
28
|
-
-
|
29
|
-
-
|
30
|
-
- lib/grb.rb
|
29
|
+
- README.rdoc
|
30
|
+
- TODO
|
31
31
|
files:
|
32
|
+
- VERSION
|
33
|
+
- README.rdoc
|
34
|
+
- TODO
|
32
35
|
- bin/grb
|
33
|
-
- Rakefile
|
34
|
-
- lib/version.rb
|
35
|
-
- lib/grb.rb
|
36
|
-
- Manifest
|
37
|
-
- grb.gemspec
|
38
36
|
has_rdoc: true
|
39
|
-
homepage: http://
|
37
|
+
homepage: http://github.com/jinzhu/grb
|
40
38
|
licenses: []
|
41
39
|
|
42
40
|
post_install_message:
|
43
41
|
rdoc_options:
|
44
|
-
- --
|
45
|
-
- --inline-source
|
46
|
-
- --title
|
47
|
-
- Grb
|
48
|
-
- --main
|
49
|
-
- README.rdoc
|
42
|
+
- --charset=UTF-8
|
50
43
|
require_paths:
|
51
44
|
- lib
|
52
45
|
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
53
47
|
requirements:
|
54
48
|
- - ">="
|
55
49
|
- !ruby/object:Gem::Version
|
50
|
+
hash: 3
|
56
51
|
segments:
|
57
52
|
- 0
|
58
53
|
version: "0"
|
59
54
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
60
56
|
requirements:
|
61
57
|
- - ">="
|
62
58
|
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
63
60
|
segments:
|
64
|
-
-
|
65
|
-
|
66
|
-
version: "1.2"
|
61
|
+
- 0
|
62
|
+
version: "0"
|
67
63
|
requirements: []
|
68
64
|
|
69
|
-
rubyforge_project:
|
70
|
-
rubygems_version: 1.3.
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 1.3.7
|
71
67
|
signing_key:
|
72
68
|
specification_version: 3
|
73
|
-
summary:
|
69
|
+
summary: A tool to simplify working with remote branches
|
74
70
|
test_files: []
|
75
71
|
|
data/Manifest
DELETED
data/Rakefile
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
require 'echoe'
|
4
|
-
require File.dirname(__FILE__) + '/lib/version'
|
5
|
-
|
6
|
-
Echoe.new('grb', Version::VERSION) do |p|
|
7
|
-
p.description = "grb"
|
8
|
-
p.url = "http://www.zhangjinzhu.com"
|
9
|
-
p.author = "Jinzhu Zhang"
|
10
|
-
p.email = "wosmvp@gmail.com"
|
11
|
-
p.ignore_pattern = ["TODO"]
|
12
|
-
p.rubyforge_name = "grb"
|
13
|
-
end
|
14
|
-
|
data/grb.gemspec
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = %q{grb}
|
5
|
-
s.version = "0.3.0"
|
6
|
-
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = ["Jinzhu Zhang"]
|
9
|
-
s.date = %q{2010-02-28}
|
10
|
-
s.default_executable = %q{grb}
|
11
|
-
s.description = %q{grb}
|
12
|
-
s.email = %q{wosmvp@gmail.com}
|
13
|
-
s.executables = ["grb"]
|
14
|
-
s.extra_rdoc_files = ["bin/grb", "lib/version.rb", "lib/grb.rb"]
|
15
|
-
s.files = ["bin/grb", "Rakefile", "lib/version.rb", "lib/grb.rb", "Manifest", "grb.gemspec"]
|
16
|
-
s.homepage = %q{http://www.zhangjinzhu.com}
|
17
|
-
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Grb", "--main", "README.rdoc"]
|
18
|
-
s.require_paths = ["lib"]
|
19
|
-
s.rubyforge_project = %q{grb}
|
20
|
-
s.rubygems_version = %q{1.3.6}
|
21
|
-
s.summary = %q{grb}
|
22
|
-
|
23
|
-
if s.respond_to? :specification_version then
|
24
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
25
|
-
s.specification_version = 3
|
26
|
-
|
27
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
28
|
-
else
|
29
|
-
end
|
30
|
-
else
|
31
|
-
end
|
32
|
-
end
|
data/lib/grb.rb
DELETED
@@ -1,125 +0,0 @@
|
|
1
|
-
class Grb
|
2
|
-
GIT = ENV['GRB_GIT'] || 'git'
|
3
|
-
ORIGIN = ENV['GRB_ORIGIN'] || 'origin'
|
4
|
-
|
5
|
-
COMMANDS = {
|
6
|
-
:new => {
|
7
|
-
:desc => "=> create new branch `branch`\ngrb new [branch] [--explain]",
|
8
|
-
:commands => [
|
9
|
-
'"#{GIT} push #{origin} #{current_branch}:refs/heads/#{branch}"',
|
10
|
-
'"#{GIT} fetch #{origin}"',
|
11
|
-
'"#{GIT} branch --track #{branch} #{origin}/#{branch}"',
|
12
|
-
'"#{GIT} checkout #{branch}"'
|
13
|
-
]
|
14
|
-
},
|
15
|
-
|
16
|
-
:push => {
|
17
|
-
:desc => "=> push branch `branch`, default current_branch\ngrb push [branch] [--explain]",
|
18
|
-
:commands => [
|
19
|
-
'"#{GIT} push #{origin} #{branch}:refs/heads/#{branch}"',
|
20
|
-
'"#{GIT} fetch #{origin}"',
|
21
|
-
'"#{GIT} config branch.#{branch}.remote #{origin}"',
|
22
|
-
'"#{GIT} config branch.#{branch}.merge refs/heads/#{branch}"',
|
23
|
-
'"#{GIT} checkout #{branch}"'
|
24
|
-
]
|
25
|
-
},
|
26
|
-
|
27
|
-
:mv => {
|
28
|
-
:desc => "=> rename `branch1` to `branch2`\ngrb mv [branch1] [branch2] [--explain]\n=> rename current branch to `branch`\ngrb mv branch [--explain]",
|
29
|
-
:commands => [
|
30
|
-
' if(branch != branch_)
|
31
|
-
"#{GIT} push #{origin} #{branch}:refs/heads/#{branch_}
|
32
|
-
#{GIT} fetch #{origin}
|
33
|
-
#{GIT} branch --track #{branch_} #{origin}/#{branch_}
|
34
|
-
#{GIT} checkout #{branch_}
|
35
|
-
#{GIT} branch -d #{branch}
|
36
|
-
#{GIT} push #{origin} :refs/heads/#{branch}"
|
37
|
-
else
|
38
|
-
"#{GIT} push #{origin} #{current_branch}:refs/heads/#{branch}
|
39
|
-
#{GIT} fetch #{origin}
|
40
|
-
#{GIT} branch --track #{branch} #{origin}/#{branch}
|
41
|
-
#{GIT} checkout #{branch}
|
42
|
-
#{GIT} push #{origin} :refs/heads/#{current_branch}
|
43
|
-
#{GIT} branch -d #{current_branch}"
|
44
|
-
end'
|
45
|
-
]
|
46
|
-
},
|
47
|
-
|
48
|
-
:rm => {
|
49
|
-
:desc => "=> delete branch `branch`,default current_branch\ngrb rm [branch] [--explain]",
|
50
|
-
:commands => [
|
51
|
-
'"#{GIT} push #{origin} :refs/heads/#{branch}"',
|
52
|
-
'"#{GIT} checkout master" if current_branch == branch',
|
53
|
-
'"#{GIT} branch -d #{branch}"'
|
54
|
-
]
|
55
|
-
},
|
56
|
-
|
57
|
-
:pull => {
|
58
|
-
:desc => "=> pull branch `branch`,default current_branch\ngrb pull [branch] [--explain]",
|
59
|
-
:commands => [
|
60
|
-
'"#{GIT} fetch #{origin}"',
|
61
|
-
'if local_branches.include?(branch)
|
62
|
-
"#{GIT} config branch.#{branch}.remote #{origin}\n" +
|
63
|
-
"#{GIT} config branch.#{branch}.merge refs/heads/#{branch}"
|
64
|
-
else
|
65
|
-
"#{GIT} branch --track #{branch} #{origin}/#{branch}"
|
66
|
-
end',
|
67
|
-
'"#{GIT} checkout #{branch}" if current_branch != branch',
|
68
|
-
'"#{GIT} merge #{origin}/#{branch}"',
|
69
|
-
]
|
70
|
-
},
|
71
|
-
|
72
|
-
:track => {
|
73
|
-
:desc => "=> track branch\ngrb track `branch` [--explain]",
|
74
|
-
:commands => [
|
75
|
-
'"#{GIT} fetch #{origin}"',
|
76
|
-
'"#{GIT} branch --track #{branch} origin/#{branch}"',
|
77
|
-
'"#{GIT} checkout #{branch}"'
|
78
|
-
]
|
79
|
-
},
|
80
|
-
|
81
|
-
:remote_add => {
|
82
|
-
:desc => "=> add a remote repo\ngrb remote_add `name` `repo path` [--explain]",
|
83
|
-
:commands => [
|
84
|
-
'"#{GIT} remote add #{branch} #{branch_}"',
|
85
|
-
'"#{GIT} fetch #{branch}"'
|
86
|
-
]
|
87
|
-
},
|
88
|
-
|
89
|
-
:remote_rm => {
|
90
|
-
:desc => "=> remove a remote repo\ngrb remote_rm `name` [--explain]",
|
91
|
-
:commands => [
|
92
|
-
'"#{GIT} remote rm #{branch}"',
|
93
|
-
]
|
94
|
-
}
|
95
|
-
}
|
96
|
-
|
97
|
-
def self.parse(opt)
|
98
|
-
if COMMANDS.keys.include?(opt[:command].to_sym)
|
99
|
-
current_branch,branch,branch_,origin = get_current_branch,opt[:branch],opt[:branch_],ORIGIN
|
100
|
-
|
101
|
-
COMMANDS[opt[:command].to_sym][:commands].map {|x| exec_cmd(eval(x))}
|
102
|
-
else
|
103
|
-
help
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def self.exec_cmd(str)
|
108
|
-
return true unless str
|
109
|
-
puts("\e[031m" + str.gsub(/^\s*/,'') + "\e[0m")
|
110
|
-
system("#{str}") unless EXPLAIN
|
111
|
-
end
|
112
|
-
|
113
|
-
def self.get_current_branch
|
114
|
-
(`#{GIT} branch 2> /dev/null | grep '^\*'`).gsub(/\W/,'')
|
115
|
-
end
|
116
|
-
|
117
|
-
def self.local_branches
|
118
|
-
(`#{GIT} branch -l`).split(/\n/).map{|x| x.gsub(/\W/,'')}
|
119
|
-
end
|
120
|
-
|
121
|
-
def self.help(*args)
|
122
|
-
puts "USAGE:"
|
123
|
-
COMMANDS.values.map {|x| puts x[:desc].gsub(/^(\W.*)$/,"\e[31m" + '\1' + "\e[0m").gsub(/^(\w.*)$/,' $ \1')}
|
124
|
-
end
|
125
|
-
end
|
data/lib/version.rb
DELETED