Skip to content

Commit 0d7de4b

Browse files
committed
Allow for naming a git remote/branch
1 parent df53409 commit 0d7de4b

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

msfupdate

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,22 @@ end
5757
when /--config-dir=(.*)?/
5858
# Spaces in the directory should be fine since this whole thing is passed
5959
# as a single argument via the multi-arg syntax for system() below.
60-
# TODO: Test this spaces business. I don't buy it. -todb
6160
@configdir = $1
6261
@configdir_index = i
62+
when /--git-remote=([^\s]*)?/
63+
@git_remote = $1
64+
@git_remote_index = i
65+
when /--git-branch=([^\s]*)?/
66+
@git_branch = $1
67+
@git_branch_index = i
6368
end
6469
end
6570

6671
@args[@wait_index] = nil if @wait_index
6772
@args[@configdir_index] = nil if @configdir_index
73+
74+
@args[@git_remote_index] = nil if @git_remote_index
75+
@args[@git_branch_index] = nil if @git_branch_index
6876
@args = @args.compact
6977

7078
####### Since we're SVN, do it all this way #######
@@ -89,7 +97,11 @@ end
8997

9098
####### Since we're Git, do it all that way #######
9199
if is_git
100+
remote = @git_remote || "origin"
101+
branch = @git_branch || "master"
92102
# Always lose any local changes, but not unchecked files
103+
# This is actually safer than the old svn way of msfupdate
104+
# which would happily just generate conflicts over changes.
93105
# TODO: Allow for git stash and git stash pop
94106
res = system("git", "reset", "HEAD", "--hard")
95107
if res.nil?
@@ -101,10 +113,9 @@ if is_git
101113
exit 1
102114
end
103115

104-
# TODO: Allow msfupdate to take a branch argument
105-
system("git", "checkout", "master")
116+
system("git", "checkout", branch)
106117
system("git", "fetch")
107-
system("git", "merge", "origin/master")
118+
system("git", "merge", "#{remote}/#{branch}")
108119
end
109120

110121
unless is_svn || is_git

0 commit comments

Comments
 (0)