Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Space. The final frontier.

  • Loading branch information...
commit d0fff4b5610d20e2e9b8924af71146f1c31dbef5 1 parent 839d93c
@webmat authored
View
2  lib/constants.rb
@@ -1,5 +1,5 @@
module GitRemoteBranch
GIT = (ENV['GRB_GIT'] || 'git')
-
+
LOCAL_BRANCH_LISTING_COMMAND = "#{GIT} branch -l"
end
View
12 lib/git_remote_branch.rb
@@ -84,7 +84,7 @@ class NotOnGitRepositoryError < RuntimeError; end
]
}
} unless defined?(COMMANDS)
-
+
def self.get_reverse_map(commands)
h={}
commands.each_pair do |cmd, params|
@@ -99,7 +99,7 @@ def self.get_reverse_map(commands)
h
end
ALIAS_REVERSE_MAP = get_reverse_map(COMMANDS) unless defined?(ALIAS_REVERSE_MAP)
-
+
def get_welcome
"git_remote_branch version #{VERSION::STRING}\n\n"
end
@@ -112,16 +112,16 @@ def get_usage
" grb #{action} branch_name [origin_server]"
} * "\n"
}
-
+
Notes:
- If origin_server is not specified, the name 'origin' is assumed (git's default)
- The rename functionality renames the current branch
-
+
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.
- Example:
+ Example:
grb explain create
grb explain create my_branch github
-
+
All commands also have aliases:
#{ COMMANDS.keys.map{|k| k.to_s}.sort.map {|cmd|
"#{cmd}: #{COMMANDS[cmd.to_sym][:aliases].join(', ')}" }.join("\n ") }
View
16 lib/param_reader.rb
@@ -1,25 +1,25 @@
module GitRemoteBranch
-
- private
+
+ private
HELP_PARAMS = {:action => :help}
public
def read_params(argv)
#TODO Some validation on the params
-
+
p={}
p[:silent] = silent!(argv)
p[:explain] = explain_mode!(argv)
-
+
p[:action] = get_action(argv[0]) or return HELP_PARAMS
return HELP_PARAMS if p[:action] == :help
p[:branch] = get_branch(argv[1])
p[:origin] = get_origin(argv[2])
-
+
# If in explain mode, the user doesn't have to specify a branch or be on in
- # actual repo to get the explanation.
+ # actual repo to get the explanation.
# Of course if he is, the explanation will be made better by using contextual info.
if p[:explain]
p[:branch] ||= "branch_to_#{p[:action]}"
@@ -44,7 +44,7 @@ def explain_mode!(argv)
false
end
end
-
+
def silent!(argv)
!!argv.delete('--silent')
end
@@ -56,7 +56,7 @@ def get_action(action)
def get_branch(branch)
branch
end
-
+
def get_origin(origin)
return origin || 'origin'
end
View
6 lib/version.rb
@@ -1,12 +1,12 @@
-module GitRemoteBranch
+module GitRemoteBranch
module VERSION #:nodoc:
MAJOR = 0
MINOR = 3
TINY = 1
-
+
STRING = [MAJOR, MINOR, TINY].join('.')
end
-
+
NAME = 'git_remote_branch'
COMPLETE_NAME = "#{NAME} #{VERSION::STRING}"
COMMAND_NAME = 'grb'
View
16 tasks/gem.rake
@@ -17,14 +17,14 @@ spec = Gem::Specification.new do |s|
s.has_rdoc = true
s.extra_rdoc_files << 'README.rdoc'
s.rdoc_options << '--main' << 'README.rdoc' << '--exclude' << 'lib'
-
+
s.test_files = Dir['test/**/*'].reject{|f| f =~ /test_runs/}
s.files = Dir['**/*'].reject{|f| f =~ /\Apkg|\Acoverage|\Ardoc|test_runs|\.gemspec\Z/}
-
+
s.executable = 'grb'
s.bindir = "bin"
s.require_path = "lib"
-
+
s.add_dependency( 'rainbow', '>= 1.0.1' )
end
@@ -56,29 +56,29 @@ namespace :gem do
File.open("#{GitRemoteBranch::NAME}.gemspec", 'w'){|f| f.puts YAML::dump(spec) }
puts "gemspec generated here: #{GitRemoteBranch::NAME}.gemspec"
end
-
+
desc 'Upload gem to rubyforge.org'
task :rubyforge => :gem do
sh 'rubyforge login'
sh "rubyforge add_release grb grb '#{GitRemoteBranch::VERSION::STRING}' pkg/#{spec.full_name}.gem"
sh "rubyforge add_file grb grb #{GitRemoteBranch::VERSION::STRING} pkg/#{spec.full_name}.gem"
end
-
+
desc 'Install the gem built locally'
task :install => [:clean, :gem] do
sh "#{SUDO} gem install pkg/#{spec.full_name}.gem"
end
-
+
desc "Uninstall version #{GitRemoteBranch::VERSION::STRING} of the gem"
task :uninstall do
sh "#{SUDO} gem uninstall -v #{GitRemoteBranch::VERSION::STRING} -x #{GitRemoteBranch::NAME}"
end
-
+
if WINDOWS
win_spec = spec.dup
win_spec.platform = Gem::Platform::CURRENT
win_spec.add_dependency( 'win32console', '~> 1.1' ) # Missing dependency in the 'colored' gem
-
+
desc "Generate the Windows version of the gem"
namespace :windows do
Rake::GemPackageTask.new(win_spec) do |p|

5 comments on commit d0fff4b

@sumbach

lol on the commit comment

@webmat
Owner

I actually have an alias to commit with that message :-)

@d1rk

git space ?

@webmat
Owner

@d1rk care to elaborate? :-) That's not a git command, afaik (although that would be awesome for us vim users).

@d1rk

Hehe, just an idea. Nothing, i would continue to dig deeper. But feel free to do so. :)

Please sign in to comment.
Something went wrong with that request. Please try again.