git_remote_branch 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +44 -7
- data/Rakefile +1 -1
- data/bin/grb +3 -1
- data/lib/git_remote_branch.rb +21 -1
- data/lib/param_reader.rb +1 -0
- data/test/test_helper.rb +2 -8
- metadata +1 -1
data/README
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
==== Why git_remote_branch? ====
|
2
2
|
|
3
|
-
The basic idea for git_remote_branch is to trivialize the interaction with
|
3
|
+
The basic idea for git_remote_branch is to trivialize the interaction with
|
4
4
|
remote branches in simple situations.
|
5
5
|
|
6
|
-
For now git_remote_branch assumes that the local and remote branches have the
|
6
|
+
For now git_remote_branch assumes that the local and remote branches have the
|
7
7
|
same name. Multiple origins are supported.
|
8
8
|
|
9
|
-
Another goal of git_remote_branch is to help teach the real underlying git
|
9
|
+
Another goal of git_remote_branch is to help teach the real underlying git
|
10
10
|
commands. Each operation done on your behalf is displayed at the console.
|
11
11
|
|
12
12
|
|
@@ -43,24 +43,60 @@ Switch to the new branch.
|
|
43
43
|
$ grb create branch_name [origin_server]
|
44
44
|
|
45
45
|
|
46
|
-
== delete (aliases: destroy, kill) ==
|
46
|
+
== delete (aliases: destroy, kill, remove) ==
|
47
47
|
Delete the remote branch then delete the local branch.
|
48
48
|
The local branch is not deleted if there are pending changes.
|
49
49
|
|
50
50
|
$ grb delete branch_name [origin_server]
|
51
51
|
|
52
52
|
|
53
|
-
== track (aliases: follow grab) ==
|
53
|
+
== track (aliases: follow grab fetch) ==
|
54
54
|
Track an existing remote branch locally.
|
55
55
|
|
56
|
-
|
57
56
|
$ grb track branch_name [origin_server]
|
58
57
|
|
59
58
|
|
59
|
+
== rename (aliases: rn, mv, move) ==
|
60
|
+
Rename the remote branch by copying and deleting the old name.
|
61
|
+
Checkout a new local tracking branch with the new name and delete the branch
|
62
|
+
with the old name.
|
63
|
+
branch_name is the new name, the old name is always the current branch's
|
64
|
+
|
65
|
+
$ grb rename branch_name [origin_server]
|
66
|
+
|
67
|
+
|
68
|
+
== explain ==
|
69
|
+
|
70
|
+
All commands can be prepended by the word 'explain'. Instead of executing the
|
71
|
+
command, git_remote_branch will simply output the list of commands you need to
|
72
|
+
run to accomplish that goal.
|
73
|
+
Examples:
|
74
|
+
|
75
|
+
$ grb explain create
|
76
|
+
git_remote_branch version 0.2.2
|
77
|
+
|
78
|
+
List of operations to do to create a new remote branch and track it locally:
|
79
|
+
|
80
|
+
git push origin master:refs/heads/branch_to_create
|
81
|
+
git fetch origin
|
82
|
+
git branch --track branch_to_create origin/branch_to_create
|
83
|
+
git checkout branch_to_create
|
84
|
+
|
85
|
+
|
86
|
+
$ grb explain create my_branch github
|
87
|
+
git_remote_branch version 0.2.2
|
88
|
+
|
89
|
+
List of operations to do to create a new remote branch and track it locally:
|
90
|
+
|
91
|
+
git push github master:refs/heads/my_branch
|
92
|
+
git fetch github
|
93
|
+
git branch --track my_branch github/my_branch
|
94
|
+
git checkout my_branch
|
95
|
+
|
60
96
|
|
61
97
|
==== History ====
|
62
98
|
|
63
|
-
This script was originally created by Carl Mercier and made public on his blog
|
99
|
+
This script was originally created by Carl Mercier and made public on his blog
|
64
100
|
here:
|
65
101
|
|
66
102
|
No nonsense GIT, part 1: git-remote-branch
|
@@ -75,3 +111,4 @@ repositories.
|
|
75
111
|
|
76
112
|
- Mathieu Martin webmat@gmail.com
|
77
113
|
- Carl Mercier (Carl: want your email here?)
|
114
|
+
- Caio Chassot dev@caiochassot.com
|
data/Rakefile
CHANGED
@@ -43,7 +43,7 @@ namespace :gem do
|
|
43
43
|
|
44
44
|
desc "Uninstall the .gem"
|
45
45
|
task :uninstall do
|
46
|
-
cmd = "#{SUDO} gem uninstall #{NAME}"
|
46
|
+
cmd = "#{SUDO} gem uninstall #{NAME} -x"
|
47
47
|
#TODO fix this crap
|
48
48
|
puts cmd, ' (Note: execute manually if more than one version is installed)'
|
49
49
|
`#{cmd}`
|
data/bin/grb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
# Check out the README (or try 'grb help') before you screw up your repos ;-)
|
4
4
|
|
5
|
-
|
5
|
+
THIS_FILE = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
|
6
|
+
require "#{File.dirname(THIS_FILE)}/../lib/git_remote_branch"
|
6
7
|
|
7
8
|
include GitRemoteBranch
|
8
9
|
|
@@ -20,3 +21,4 @@ if p[:explain]
|
|
20
21
|
else
|
21
22
|
execute_action(p[:action], p[:branch], p[:origin], p[:current_branch])
|
22
23
|
end
|
24
|
+
|
data/lib/git_remote_branch.rb
CHANGED
@@ -21,9 +21,22 @@ module GitRemoteBranch
|
|
21
21
|
]
|
22
22
|
},
|
23
23
|
|
24
|
+
:rename => {
|
25
|
+
:description => 'rename a remote branch and its local tracking branch',
|
26
|
+
:aliases => %w{ rn mv move },
|
27
|
+
:commands => [
|
28
|
+
'"git push #{origin} #{current_branch}:refs/heads/#{branch_name}"',
|
29
|
+
'"git fetch #{origin}"',
|
30
|
+
'"git branch --track #{branch_name} #{origin}/#{branch_name}"',
|
31
|
+
'"git checkout #{branch_name}"',
|
32
|
+
'"git push #{origin} :refs/heads/#{current_branch}"',
|
33
|
+
'"git branch -d #{current_branch}"',
|
34
|
+
]
|
35
|
+
},
|
36
|
+
|
24
37
|
:delete => {
|
25
38
|
:description => 'delete a local and a remote branch',
|
26
|
-
:aliases => %w{delete destroy kill remove},
|
39
|
+
:aliases => %w{delete destroy kill remove rm},
|
27
40
|
:commands => [
|
28
41
|
'"git push #{origin} :refs/heads/#{branch_name}"',
|
29
42
|
'"git checkout master" if current_branch == branch_name',
|
@@ -54,10 +67,17 @@ module GitRemoteBranch
|
|
54
67
|
|
55
68
|
grb delete branch_name [origin_server]
|
56
69
|
|
70
|
+
grb rename branch_name [origin_server]
|
71
|
+
|
57
72
|
grb track branch_name [origin_server]
|
58
73
|
|
59
74
|
If origin_server is not specified, the name 'origin' is assumed (git's default)
|
60
75
|
|
76
|
+
The explain meta-command: you can also prepend any command with the keyword 'explain'. Instead of executing the command, git_remote_branch will simply output the list of commands you need to run to accomplish that goal.
|
77
|
+
Example:
|
78
|
+
grb explain create
|
79
|
+
grb explain create my_branch github
|
80
|
+
|
61
81
|
All commands also have aliases:
|
62
82
|
#{ COMMANDS.keys.map{|k| k.to_s}.sort.map {|cmd|
|
63
83
|
"#{cmd}: #{COMMANDS[cmd.to_sym][:aliases].join(', ')}" }.join("\n ") }
|
data/lib/param_reader.rb
CHANGED
@@ -29,6 +29,7 @@ module GitRemoteBranch
|
|
29
29
|
return :create if COMMANDS[:create][:aliases].include?(a)
|
30
30
|
return :delete if COMMANDS[:delete][:aliases].include?(a)
|
31
31
|
return :track if COMMANDS[:track][:aliases].include?(a)
|
32
|
+
return :rename if COMMANDS[:rename][:aliases].include?(a)
|
32
33
|
return nil
|
33
34
|
end
|
34
35
|
|
data/test/test_helper.rb
CHANGED
@@ -3,14 +3,8 @@ require 'test/unit'
|
|
3
3
|
|
4
4
|
test_dir = File.dirname(__FILE__)
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
rescue LoadError
|
9
|
-
require File.join( [test_dir] + %w{ .. vendor try_require try_require } )
|
10
|
-
end
|
11
|
-
|
12
|
-
try_require 'redgreen'
|
13
|
-
try_require 'ruby-debug'
|
6
|
+
require 'redgreen'
|
7
|
+
require 'ruby-debug'
|
14
8
|
|
15
9
|
require File.join(test_dir, 'git_helper')
|
16
10
|
require File.join( [test_dir] + %w{ .. lib git_remote_branch} )
|