From 558bc5b0226ad39d0fcf1d38ce49d98d62878d51 Mon Sep 17 00:00:00 2001 From: Tony Duckles Date: Tue, 1 Nov 2011 21:42:31 -0500 Subject: [PATCH] hub version 1.6.1 --- bin/hub | 1229 ++++++++++++++++++++++++++++++++++++++++++++++++ bin/latest-ack | 5 +- bin/latest-hub | 3 +- 3 files changed, 1234 insertions(+), 3 deletions(-) create mode 100755 bin/hub diff --git a/bin/hub b/bin/hub new file mode 100755 index 0000000..74ca08d --- /dev/null +++ b/bin/hub @@ -0,0 +1,1229 @@ +#!/usr/bin/env ruby +# +# This file, hub, is generated code. +# Please DO NOT EDIT or send patches for it. +# +# Please take a look at the source from +# http://github.com/defunkt/hub +# and submit patches against the individual files +# that build hub. +# + +module Hub + class Args < Array + attr_accessor :executable + + def initialize(*args) + super + @executable = ENV["GIT"] || "git" + @after = nil + @skip = false + @original_args = args.first + @chain = [nil] + end + + def after(cmd_or_args = nil, args = nil, &block) + @chain.insert(-1, normalize_callback(cmd_or_args, args, block)) + end + + def before(cmd_or_args = nil, args = nil, &block) + @chain.insert(@chain.index(nil), normalize_callback(cmd_or_args, args, block)) + end + + def chained? + @chain.size > 1 + end + + def commands + chain = @chain.dup + chain[chain.index(nil)] = self.to_exec + chain + end + + def skip! + @skip ||= true + end + + def skip? + @skip + end + + def to_exec(args = self) + Array(executable) + args + end + + def words + reject { |arg| arg.index('-') == 0 } + end + + def flags + self - words + end + + def changed? + chained? or self != @original_args + end + + def has_flag?(*flags) + pattern = flags.flatten.map { |f| Regexp.escape(f) }.join('|') + !grep(/^#{pattern}(?:=|$)/).empty? + end + + private + + def normalize_callback(cmd_or_args, args, block) + if block + block + elsif args + [cmd_or_args].concat args + elsif Array === cmd_or_args + self.to_exec cmd_or_args + elsif cmd_or_args + cmd_or_args + else + raise ArgumentError, "command or block required" + end + end + end +end +module Hub + module Context; end + + module Commands + instance_methods.each { |m| undef_method(m) unless m =~ /(^__|send|to\?$)/ } + extend self + + extend Context + + API_REPO = 'http://github.com/api/v2/yaml/repos/show/%s/%s' + API_FORK = 'http://github.com/api/v2/yaml/repos/fork/%s/%s' + API_CREATE = 'http://github.com/api/v2/yaml/repos/create' + + def run(args) + slurp_global_flags(args) + + args.unshift 'help' if args.empty? + + cmd = args[0] + expanded_args = expand_alias(cmd) + cmd = expanded_args[0] if expanded_args + + cmd = cmd.sub(/(\w)-/, '\1_') + if method_defined?(cmd) and cmd != 'run' + args[0, 1] = expanded_args if expanded_args + send(cmd, args) + end + end + + def clone(args) + ssh = args.delete('-p') + has_values = /^(--(upload-pack|template|depth|origin|branch|reference)|-[ubo])$/ + + idx = 1 + while idx < args.length + arg = args[idx] + if arg.index('-') == 0 + idx += 1 if arg =~ has_values + elsif arg.index('://') or arg.index('@') or File.directory?(arg) + break + elsif arg.scan('/').size <= 1 && !arg.include?(':') + args[args.index(arg)] = github_url(:repo => arg, :private => ssh) + break + end + idx += 1 + end + end + + def submodule(args) + return unless index = args.index('add') + args.delete_at index + + branch = args.index('-b') || args.index('--branch') + if branch + args.delete_at branch + branch_name = args.delete_at branch + end + + clone(args) + + if branch_name + args.insert branch, '-b', branch_name + end + args.insert index, 'add' + end + + def remote(args) + return unless ['add','set-url'].include?(args[1]) && args.last !~ %r{.+?://|.+?@|^[./]} + + ssh = args.delete('-p') + + args.last =~ /\b(.+?)(?:\/(.+))?$/ + user, repo = $1, $2 + + if args.words[2] == 'origin' && args.words[3].nil? + user = repo = nil + elsif args.words[-2] == args.words[1] + idx = args.index( args.words[-1] ) + args[idx] = user + else + args.replace args[0...-1] + end + + args << github_url(:user => user, :repo => repo, :private => ssh) + end + + def fetch(args) + if args.include?('--multiple') + names = args.words[1..-1] + elsif remote_name = args.words[1] + if remote_name =~ /^\w+(,\w+)+$/ + index = args.index(remote_name) + args.delete(remote_name) + names = remote_name.split(',') + args.insert(index, *names) + args.insert(index, '--multiple') + else + names = [remote_name] + end + else + names = [] + end + + names.reject! { |name| + name =~ /\W/ or remotes.include?(name) or + remotes_group(name) or not repo_exists?(name) + } + + if names.any? + names.each do |name| + args.before ['remote', 'add', name, github_url(:user => name)] + end + end + end + + def cherry_pick(args) + unless args.include?('-m') or args.include?('--mainline') + case ref = args.words.last + when %r{^(?:https?:)//github.com/(.+?)/(.+?)/commit/([a-f0-9]{7,40})} + user, repo, sha = $1, $2, $3 + args[args.index(ref)] = sha + when /^(\w+)@([a-f1-9]{7,40})$/ + user, repo, sha = $1, nil, $2 + args[args.index(ref)] = sha + else + user = nil + end + + if user + if user == repo_owner + args.before ['fetch', default_remote] + elsif remotes.include?(user) + args.before ['fetch', user] + else + remote_url = github_url(:user => user, :repo => repo, :private => false) + args.before ['remote', 'add', '-f', user, remote_url] + end + end + end + end + + def am(args) + if url = args.find { |a| a =~ %r{^https?://(gist\.)?github\.com/} } + idx = args.index(url) + gist = $1 == 'gist.' + url = url.sub(%r{(/pull/\d+)/\w*$}, '\1') unless gist + ext = gist ? '.txt' : '.patch' + url += ext unless File.extname(url) == ext + patch_file = File.join(ENV['TMPDIR'], "#{gist ? 'gist-' : ''}#{File.basename(url)}") + args.before 'curl', ['-#LA', "hub #{Hub::Version}", url, '-o', patch_file] + args[idx] = patch_file + end + end + + def init(args) + if args.delete('-g') + url = github_url(:private => true, :repo => current_dirname) + args.after "git remote add origin #{url}" + end + end + + def fork(args) + if github_user && github_token && repo_owner + if repo_exists?(github_user) + puts "#{github_user}/#{repo_name} already exists on GitHub" + else + fork_repo + end + + if args.include?('--no-remote') + exit + else + url = github_url(:private => true) + args.replace %W"remote add -f #{github_user} #{url}" + args.after { puts "new remote: #{github_user}" } + end + end + rescue Net::HTTPExceptions + response = $!.response + warn "error creating fork: #{response.message} (HTTP #{response.code})" + exit 1 + end + + def create(args) + if !is_repo? + puts "'create' must be run from inside a git repository" + args.skip! + elsif github_user && github_token + args.shift + options = {} + options[:private] = true if args.delete('-p') + + until args.empty? + case arg = args.shift + when '-d' + options[:description] = args.shift + when '-h' + options[:homepage] = args.shift + else + puts "unexpected argument: #{arg}" + return + end + end + + if repo_exists?(github_user) + puts "#{github_user}/#{repo_name} already exists on GitHub" + action = "set remote origin" + else + action = "created repository" + create_repo(options) + end + + url = github_url(:private => true) + + if remotes.first != 'origin' + args.replace %W"remote add -f origin #{url}" + else + args.replace %W"remote -v" + end + + args.after { puts "#{action}: #{github_user}/#{repo_name}" } + end + rescue Net::HTTPExceptions + response = $!.response + warn "error creating repository: #{response.message} (HTTP #{response.code})" + exit 1 + end + + def push(args) + return if args[1].nil? || !args[1].index(',') + + branch = (args[2] ||= normalize_branch(current_branch)) + remotes = args[1].split(',') + args[1] = remotes.shift + + remotes.each do |name| + args.after ['push', name, branch] + end + end + + def browse(args) + args.shift + browse_command(args) do + user = repo = nil + dest = args.shift + dest = nil if dest == '--' + + if dest + repo = dest + elsif repo_user + user = repo_user + else + abort "Usage: hub browse [/]" + end + + params = { :user => user, :repo => repo } + + case subpage = args.shift + when 'commits' + branch = (!dest && tracked_branch) || 'master' + params[:web] = "/commits/#{branch}" + when 'tree', NilClass + branch = !dest && tracked_branch + params[:web] = "/tree/#{branch}" if branch && branch != 'master' + else + params[:web] = "/#{subpage}" + end + + params + end + end + + def compare(args) + args.shift + browse_command(args) do + if args.empty? + branch = tracked_branch + if branch && branch != 'master' + range, user = branch, repo_user + else + abort "Usage: hub compare [USER] [...]" + end + else + range = args.pop + user = args.pop || repo_user + end + { :user => user, :web => "/compare/#{range}" } + end + end + + def hub(args) + return help(args) unless args[1] == 'standalone' + require 'hub/standalone' + puts Hub::Standalone.build + exit + rescue LoadError + abort "hub is running in standalone mode." + end + + def alias(args) + shells = { + 'sh' => 'alias git=hub', + 'bash' => 'alias git=hub', + 'zsh' => 'function git(){hub "$@"}', + 'csh' => 'alias git hub', + 'fish' => 'alias git hub' + } + + silent = args.delete('-s') + + if shell = args[1] + if silent.nil? + puts "Run this in your shell to start using `hub` as `git`:" + print " " + end + else + puts "usage: hub alias [-s] SHELL", "" + puts "You already have hub installed and available in your PATH," + puts "but to get the full experience you'll want to alias it to" + puts "`git`.", "" + puts "To see how to accomplish this for your shell, run the alias" + puts "command again with the name of your shell.", "" + puts "Known shells:" + shells.map { |key, _| key }.sort.each do |key| + puts " " + key + end + puts "", "Options:" + puts " -s Silent. Useful when using the output with eval, e.g." + puts " $ eval `hub alias -s bash`" + + exit + end + + if shells[shell] + puts shells[shell] + else + abort "fatal: never heard of `#{shell}'" + end + + exit + end + + def version(args) + args.after do + puts "hub version %s" % Version + end + end + alias_method "--version", :version + + def help(args) + command = args.words[1] + + if command == 'hub' + puts hub_manpage + exit + elsif command.nil? && !args.has_flag?('-a', '--all') + ENV['GIT_PAGER'] = '' unless args.has_flag?('-p', '--paginate') # Use `cat`. + puts improved_help_text + exit + end + end + alias_method "--help", :help + + def improved_help_text + <<-help +usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path] + [-p|--paginate|--no-pager] [--bare] [--git-dir=GIT_DIR] + [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS] + +Basic Commands: + init Create an empty git repository or reinitialize an existing one + add Add new or modified files to the staging area + rm Remove files from the working directory and staging area + mv Move or rename a file, a directory, or a symlink + status Show the status of the working directory and staging area + commit Record changes to the repository + +History Commands: + log Show the commit history log + diff Show changes between commits, commit and working tree, etc + show Show information about commits, tags or files + +Branching Commands: + branch List, create, or delete branches + checkout Switch the active branch to another branch + merge Join two or more development histories (branches) together + tag Create, list, delete, sign or verify a tag object + +Remote Commands: + clone Clone a remote repository into a new directory + fetch Download data, tags and branches from a remote repository + pull Fetch from and merge with another repository or a local branch + push Upload data, tags and branches to a remote repository + remote View and manage a set of remote repositories + +Advanced commands: + reset Reset your staging area or working directory to another point + rebase Re-apply a series of patches in one branch onto another + bisect Find by binary search the change that introduced a bug + grep Print files with lines matching a pattern in your codebase + +See 'git help COMMAND' for more information on a specific command. +help + end + + private + + def slurp_global_flags(args) + flags = %w[ -c -p --paginate --no-pager --no-replace-objects --bare --version --help ] + flags2 = %w[ --exec-path= --git-dir= --work-tree= ] + + globals = [] + locals = [] + + while args[0] && (flags.include?(args[0]) || flags2.any? {|f| args[0].index(f) == 0 }) + flag = args.shift + case flag + when '--version', '--help' + args.unshift flag.sub('--', '') + when '-c' + config_pair = args.shift + key, value = config_pair.split('=', 2) + Context::GIT_CONFIG["config #{key}"] = value.to_s + + globals << flag << config_pair + when '-p', '--paginate', '--no-pager' + locals << flag + else + globals << flag + end + end + + Context::GIT_CONFIG.executable = Array(Context::GIT_CONFIG.executable).concat(globals) + args.executable = Array(args.executable).concat(globals).concat(locals) + end + + def browse_command(args) + url_only = args.delete('-u') + $stderr.puts "Warning: the `-p` flag has no effect anymore" if args.delete('-p') + params = yield + + args.executable = url_only ? 'echo' : browser_launcher + args.push github_url({:web => true, :private => true}.update(params)) + end + + def hub_manpage + return "** Can't find groff(1)" unless command?('groff') + + require 'open3' + out = nil + Open3.popen3(groff_command) do |stdin, stdout, _| + stdin.puts hub_raw_manpage + stdin.close + out = stdout.read.strip + end + out + end + + def groff_command + "groff -Wall -mtty-char -mandoc -Tascii" + end + + def hub_raw_manpage + if File.exists? file = File.dirname(__FILE__) + '/../../man/hub.1' + File.read(file) + else + DATA.read + end + end + + def puts(*args) + page_stdout + super + end + + def page_stdout + return unless $stdout.tty? + + read, write = IO.pipe + + if Kernel.fork + $stdin.reopen(read) + read.close + write.close + + ENV['LESS'] = 'FSRX' + + Kernel.select [STDIN] + + pager = ENV['GIT_PAGER'] || + `git config --get-all core.pager`.split.first || ENV['PAGER'] || + 'less -isr' + + pager = 'cat' if pager.empty? + + exec pager rescue exec "/bin/sh", "-c", pager + else + $stdout.reopen(write) + $stderr.reopen(write) if $stderr.tty? + read.close + write.close + end + end + + def repo_exists?(user) + require 'net/http' + url = API_REPO % [user, repo_name] + Net::HTTPSuccess === Net::HTTP.get_response(URI(url)) + end + + def fork_repo + url = API_FORK % [repo_owner, repo_name] + response = Net::HTTP.post_form(URI(url), 'login' => github_user, 'token' => github_token) + response.error! unless Net::HTTPSuccess === response + end + + def create_repo(options = {}) + url = API_CREATE + params = {'login' => github_user, 'token' => github_token, 'name' => repo_name} + params['public'] = '0' if options[:private] + params['description'] = options[:description] if options[:description] + params['homepage'] = options[:homepage] if options[:homepage] + + response = Net::HTTP.post_form(URI(url), params) + response.error! unless Net::HTTPSuccess === response + end + + def expand_alias(cmd) + if expanded = git_alias_for(cmd) + if expanded.index('!') != 0 + require 'shellwords' unless defined?(::Shellwords) + Shellwords.shellwords(expanded) + end + end + end + + end +end +require 'shellwords' + +module Hub + module Context + private + + class ShellOutCache < Hash + attr_accessor :executable + + def initialize(executable = nil, &block) + super(&block) + @executable = executable + end + + def to_exec(args) + args = Shellwords.shellwords(args) if args.respond_to? :to_str + Array(executable) + Array(args) + end + end + + GIT_CONFIG = ShellOutCache.new(ENV['GIT'] || 'git') do |cache, cmd| + full_cmd = cache.to_exec(cmd) + cmd_string = full_cmd.respond_to?(:shelljoin) ? full_cmd.shelljoin : full_cmd.join(' ') + result = %x{#{cmd_string}}.chomp + cache[cmd] = $?.success? && !result.empty? ? result : nil + end + + REMOTES = Hash.new do |cache, remote| + if remote + urls = GIT_CONFIG["config --get-all remote.#{remote}.url"].to_s.split("\n") + + if urls.find { |u| u =~ %r{\bgithub\.com[:/](.+)/(.+).git$} } + cache[remote] = { :user => $1, :repo => $2 } + else + cache[remote] = { } + end + else + cache[remote] = { } + end + end + + LGHCONF = "http://help.github.com/git-email-settings/" + + def repo_owner + REMOTES[default_remote][:user] + end + + def repo_user + REMOTES[current_remote][:user] + end + + def repo_name + REMOTES[default_remote][:repo] || current_dirname + end + + def github_user(fatal = true) + if user = ENV['GITHUB_USER'] || GIT_CONFIG['config github.user'] + user + elsif fatal + abort("** No GitHub user set. See #{LGHCONF}") + end + end + + def github_token(fatal = true) + if token = ENV['GITHUB_TOKEN'] || GIT_CONFIG['config github.token'] + token + elsif fatal + abort("** No GitHub token set. See #{LGHCONF}") + end + end + + def current_branch + GIT_CONFIG['symbolic-ref -q HEAD'] + end + + def tracked_branch + branch = current_branch && tracked_for(current_branch) + normalize_branch(branch) if branch + end + + def remotes + list = GIT_CONFIG['remote'].to_s.split("\n") + main = list.delete('origin') and list.unshift(main) + list + end + + def remotes_group(name) + GIT_CONFIG["config remotes.#{name}"] + end + + def current_remote + return if remotes.empty? + (current_branch && remote_for(current_branch)) || default_remote + end + + def default_remote + remotes.first + end + + def normalize_branch(branch) + branch.sub('refs/heads/', '') + end + + def remote_for(branch) + GIT_CONFIG['config branch.%s.remote' % normalize_branch(branch)] + end + + def tracked_for(branch) + GIT_CONFIG['config branch.%s.merge' % normalize_branch(branch)] + end + + def http_clone? + GIT_CONFIG['config --bool hub.http-clone'] == 'true' + end + + def git_alias_for(name) + GIT_CONFIG["config alias.#{name}"] + end + + def is_repo? + GIT_CONFIG['config core.repositoryformatversion'] + end + + def github_url(options = {}) + repo = options[:repo] + user, repo = repo.split('/') if repo && repo.index('/') + user ||= options[:user] || github_user + repo ||= repo_name + secure = options[:private] + + if options[:web] + scheme = secure ? 'https:' : 'http:' + path = options[:web] == true ? '' : options[:web].to_s + if repo =~ /\.wiki$/ + repo = repo.sub(/\.wiki$/, '') + unless '/wiki' == path + path = '/wiki%s' % if path =~ %r{^/commits/} then '/_history' + else path.sub(/\w+/, '_\0') + end + end + end + '%s//github.com/%s/%s%s' % [scheme, user, repo, path] + else + if secure + url = 'git@github.com:%s/%s.git' + elsif http_clone? + url = 'http://github.com/%s/%s.git' + else + url = 'git://github.com/%s/%s.git' + end + + url % [user, repo] + end + end + + DIRNAME = File.basename(Dir.pwd) + + def current_dirname + DIRNAME + end + + def browser_launcher + require 'rbconfig' + browser = ENV['BROWSER'] || + (RbConfig::CONFIG['host_os'].include?('darwin') && 'open') || + (RbConfig::CONFIG['host_os'] =~ /msdos|mswin|djgpp|mingw|windows/ && 'start') || + %w[xdg-open cygstart x-www-browser firefox opera mozilla netscape].find { |comm| which comm } + + abort "Please set $BROWSER to a web launcher to use this command." unless browser + Array(browser) + end + + def which(cmd) + exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] + ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| + exts.each { |ext| + exe = "#{path}/#{cmd}#{ext}" + return exe if File.executable? exe + } + end + return nil + end + + def command?(name) + !which(name).nil? + end + end +end +module Hub + class Runner + attr_reader :args + + def initialize(*args) + @args = Args.new(args) + Commands.run(@args) + end + + def self.execute(*args) + new(*args).execute + end + + def command + if args.skip? + '' + else + commands.join('; ') + end + end + + def commands + args.commands.map do |cmd| + if cmd.respond_to?(:join) + cmd.map { |c| (c.index(' ') || c.empty?) ? "'#{c}'" : c }.join(' ') + else + cmd.to_s + end + end + end + + def execute + unless args.skip? + if args.chained? + execute_command_chain + else + exec(*args.to_exec) + end + end + end + + def execute_command_chain + commands = args.commands + commands.each_with_index do |cmd, i| + if cmd.respond_to?(:call) then cmd.call + elsif i == commands.length - 1 + exec(*cmd) + else + exit($?.exitstatus) unless system(*cmd) + end + end + end + end +end +module Hub + Version = VERSION = '1.6.1' +end +Hub::Runner.execute(*ARGV) +__END__ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "HUB" "1" "May 2011" "DEFUNKT" "Git Manual" +. +.SH "NAME" +\fBhub\fR \- git + hub = github +. +.SH "SYNOPSIS" +\fBhub\fR \fICOMMAND\fR \fIOPTIONS\fR +. +.br +\fBhub alias\fR [\fB\-s\fR] \fISHELL\fR +. +.P +\fBgit init \-g\fR \fIOPTIONS\fR +. +.br +\fBgit create\fR [\fB\-p\fR] [\fB\-d \fR] [\fB\-h \fR] +. +.br +\fBgit clone\fR [\fB\-p\fR] \fIOPTIONS\fR [\fIUSER\fR/]\fIREPOSITORY\fR \fIDIRECTORY\fR +. +.br +\fBgit remote add\fR [\fB\-p\fR] \fIOPTIONS\fR \fIUSER\fR[/\fIREPOSITORY\fR] +. +.br +\fBgit remote set\-url\fR [\fB\-p\fR] \fIOPTIONS\fR \fIREMOTE\-NAME\fR \fIUSER\fR[/\fIREPOSITORY\fR] +. +.br +\fBgit fetch\fR \fIUSER\-1\fR,[\fIUSER\-2\fR,\.\.\.] +. +.br +\fBgit cherry\-pick\fR \fIGITHUB\-REF\fR +. +.br +\fBgit am\fR \fIGITHUB\-URL\fR +. +.br +\fBgit push\fR \fIREMOTE\-1\fR,\fIREMOTE\-2\fR,\.\.\.,\fIREMOTE\-N\fR [\fIREF\fR] +. +.br +\fBgit browse\fR [\fB\-u\fR] [[\fIUSER\fR\fB/\fR]\fIREPOSITORY\fR] [SUBPAGE] +. +.br +\fBgit compare\fR [\fB\-u\fR] [\fIUSER\fR] [\fISTART\fR\.\.\.]\fIEND\fR +. +.br +\fBgit submodule add\fR [\fB\-p\fR] \fIOPTIONS\fR [\fIUSER\fR/]\fIREPOSITORY\fR \fIDIRECTORY\fR +. +.br +\fBgit fork\fR [\fB\-\-no\-remote\fR] +. +.SH "DESCRIPTION" +\fBhub\fR enhances various \fBgit\fR commands with GitHub remote expansion\. The alias command displays information on configuring your environment: +. +.IP "\(bu" 4 +\fBhub alias\fR [\fB\-s\fR] \fISHELL\fR: Writes shell aliasing code for \fISHELL\fR (\fBbash\fR, \fBsh\fR, \fBzsh\fR, \fBcsh\fR) to standard output\. With the \fB\-s\fR option, the output of this command can be evaluated directly within the shell: +. +.br +\fBeval $(hub alias \-s bash)\fR +. +.IP "\(bu" 4 +\fBgit init\fR \fB\-g\fR \fIOPTIONS\fR: Create a git repository as with git\-init(1) and add remote \fBorigin\fR at "git@github\.com:\fIUSER\fR/\fIREPOSITORY\fR\.git"; \fIUSER\fR is your GitHub username and \fIREPOSITORY\fR is the current working directory\'s basename\. +. +.IP "\(bu" 4 +\fBgit create\fR [\fB\-p\fR] [\fB\-d \fR] [\fB\-h \fR]: +. +.br +Create a new public github repository from the current git repository and add remote \fBorigin\fR at "git@github\.com:\fIUSER\fR/\fIREPOSITORY\fR\.git"; \fIUSER\fR is your GitHub username and \fIREPOSITORY\fR is the current working directory\'s basename\. With \fB\-p\fR, create a private repository\. \fB\-d\fR and \fB\-h\fR set the repository\'s description and homepage, respectively\. +. +.IP "\(bu" 4 +\fBgit clone\fR [\fB\-p\fR] \fIOPTIONS\fR [\fIUSER\fR\fB/\fR]\fIREPOSITORY\fR \fIDIRECTORY\fR: +. +.br +Clone repository "git://github\.com/\fIUSER\fR/\fIREPOSITORY\fR\.git" into \fIDIRECTORY\fR as with git\-clone(1)\. When \fIUSER\fR/ is omitted, assumes your GitHub login\. With \fB\-p\fR, use private remote "git@github\.com:\fIUSER\fR/\fIREPOSITORY\fR\.git"\. +. +.IP "\(bu" 4 +\fBgit remote add\fR [\fB\-p\fR] \fIOPTIONS\fR \fIUSER\fR[\fB/\fR\fIREPOSITORY\fR]: +. +.br +Add remote "git://github\.com/\fIUSER\fR/\fIREPOSITORY\fR\.git" as with git\-remote(1)\. When /\fIREPOSITORY\fR is omitted, the basename of the current working directory is used\. With \fB\-p\fR, use private remote "git@github\.com:\fIUSER\fR/\fIREPOSITORY\fR\.git"\. If \fIUSER\fR is "origin" then uses your GitHub login\. +. +.IP "\(bu" 4 +\fBgit remote set\-url\fR [\fB\-p\fR] \fIOPTIONS\fR \fIREMOTE\-NAME\fR \fIUSER\fR[/\fIREPOSITORY\fR] +. +.br +Sets the url of remote \fIREMOTE\-NAME\fR using the same rules as \fBgit remote add\fR\. +. +.IP "\(bu" 4 +\fBgit fetch\fR \fIUSER\-1\fR,[\fIUSER\-2\fR,\.\.\.]: Adds missing remote(s) with \fBgit remote add\fR prior to fetching\. New remotes are only added if they correspond to valid forks on GitHub\. +. +.IP "\(bu" 4 +\fBgit cherry\-pick\fR \fIGITHUB\-REF\fR: Cherry\-pick a commit from a fork using either full URL to the commit or GitHub\-flavored Markdown notation, which is \fBuser@sha\fR\. If the remote doesn\'t yet exist, it will be added\. A \fBgit fetch \fR is issued prior to the cherry\-pick attempt\. +. +.IP "\(bu" 4 +\fBgit am\fR \fIGITHUB\-URL\fR: Downloads the patch file for the pull request or commit at the URL and applies that patch from disk with \fBgit am\fR\. Similar to \fBcherry\-pick\fR, but doesn\'t add new remotes\. +. +.IP "\(bu" 4 +\fBgit push\fR \fIREMOTE\-1\fR,\fIREMOTE\-2\fR,\.\.\.,\fIREMOTE\-N\fR [\fIREF\fR]: Push \fIREF\fR to each of \fIREMOTE\-1\fR through \fIREMOTE\-N\fR by executing multiple \fBgit push\fR commands\. +. +.IP "\(bu" 4 +\fBgit browse\fR [\fB\-u\fR] [[\fIUSER\fR\fB/\fR]\fIREPOSITORY\fR] [SUBPAGE]: Open repository\'s GitHub page in the system\'s default web browser using \fBopen(1)\fR or the \fBBROWSER\fR env variable\. If the repository isn\'t specified, \fBbrowse\fR opens the page of the repository found in the current directory\. If SUBPAGE is specified, the browser will open on the specified subpage: one of "wiki", "commits", "issues" or other (the default is "tree")\. +. +.IP "\(bu" 4 +\fBgit compare\fR [\fB\-u\fR] [\fIUSER\fR] [\fISTART\fR\.\.\.]\fIEND\fR: Open a GitHub compare view page in the system\'s default web browser\. \fISTART\fR to \fIEND\fR are branch names, tag names, or commit SHA1s specifying the range of history to compare\. If \fISTART\fR is omitted, GitHub will compare against the base branch (the default is "master")\. +. +.IP "\(bu" 4 +\fBgit submodule add\fR [\fB\-p\fR] \fIOPTIONS\fR [\fIUSER\fR/]\fIREPOSITORY\fR \fIDIRECTORY\fR: +. +.br +Submodule repository "git://github\.com/\fIUSER\fR/\fIREPOSITORY\fR\.git" into \fIDIRECTORY\fR as with git\-submodule(1)\. When \fIUSER\fR/ is omitted, assumes your GitHub login\. With \fB\-p\fR, use private remote "git@github\.com:\fIUSER\fR/\fIREPOSITORY\fR\.git"\. +. +.IP "\(bu" 4 +\fBgit fork\fR [\fB\-\-no\-remote\fR]: Forks the original project (referenced by "origin" remote) on GitHub and adds a new remote for it under your username\. Requires \fBgithub\.token\fR to be set (see CONFIGURATION)\. +. +.IP "\(bu" 4 +\fBgit help\fR: Display enhanced git\-help(1)\. +. +.IP "" 0 +. +.SH "CONFIGURATION" +Use git\-config(1) to display the currently configured GitHub username: +. +.IP "" 4 +. +.nf + +$ git config \-\-global github\.user +. +.fi +. +.IP "" 0 +. +.P +Or, set the GitHub username and token with: +. +.IP "" 4 +. +.nf + +$ git config \-\-global github\.user +$ git config \-\-global github\.token +. +.fi +. +.IP "" 0 +. +.P +See \fIhttp://github\.com/guides/local\-github\-config\fR for more information\. +. +.P +You can also tell \fBhub\fR to use \fBhttp://\fR rather than \fBgit://\fR when cloning: +. +.IP "" 4 +. +.nf + +$ git config \-\-global \-\-bool hub\.http\-clone true +. +.fi +. +.IP "" 0 +. +.P +Want to use environment variables instead of a local gitconfig for authentication? +. +.IP "\(bu" 4 +\fBGITHUB_USER\fR \- If set, this will be used instead of the \fBgithub\.user\fR config +. +.IP "\(bu" 4 +\fBGITHUB_TOKEN\fR \- If set, this will be used instead of the \fBgithub\.token\fR +. +.IP "" 0 +. +.SH "EXAMPLES" +. +.SS "git clone" +. +.nf + +$ git clone schacon/ticgit +> git clone git://github\.com/schacon/ticgit\.git + +$ git clone \-p schacon/ticgit +> git clone git@github\.com:schacon/ticgit\.git + +$ git clone resque +> git clone git://github\.com/YOUR_USER/resque\.git + +$ git clone \-p resque +> git clone git@github\.com:YOUR_USER/resque\.git +. +.fi +. +.SS "git remote add" +. +.nf + +$ git remote add rtomayko +> git remote add rtomayko git://github\.com/rtomayko/CURRENT_REPO\.git + +$ git remote add \-p rtomayko +> git remote add rtomayko git@github\.com:rtomayko/CURRENT_REPO\.git + +$ git remote add origin +> git remote add origin git://github\.com/YOUR_USER/CURRENT_REPO\.git +. +.fi +. +.SS "git fetch" +. +.nf + +$ git fetch mislav +> git remote add mislav git://github\.com/mislav/REPO\.git +> git fetch mislav + +$ git fetch mislav,xoebus +> git remote add mislav \.\.\. +> git remote add xoebus \.\.\. +> git fetch \-\-multiple mislav xoebus +. +.fi +. +.SS "git cherry\-pick" +. +.nf + +$ git cherry\-pick http://github\.com/mislav/REPO/commit/SHA +> git remote add \-f mislav git://github\.com/mislav/REPO\.git +> git cherry\-pick SHA + +$ git cherry\-pick mislav@SHA +> git remote add \-f mislav git://github\.com/mislav/CURRENT_REPO\.git +> git cherry\-pick SHA + +$ git cherry\-pick mislav@SHA +> git fetch mislav +> git cherry\-pick SHA +. +.fi +. +.SS "git am" +. +.nf + +$ git am https://github\.com/defunkt/hub/pull/55 +> curl https://github\.com/defunkt/hub/pull/55\.patch \-o /tmp/55\.patch +> git am /tmp/55\.patch + +$ git am \-\-ignore\-whitespace https://github\.com/davidbalbert/hub/commit/fdb9921 +> curl https://github\.com/davidbalbert/hub/commit/fdb9921\.patch \-o /tmp/fdb9921\.patch +> git am \-\-ignore\-whitespace /tmp/fdb9921\.patch +. +.fi +. +.SS "git fork" +. +.nf + +$ git fork +\.\.\. hardcore forking action \.\.\. +> git remote add YOUR_USER git@github\.com:YOUR_USER/CURRENT_REPO\.git +. +.fi +. +.SS "git init" +. +.nf + +$ git init \-g +> git init +> git remote add origin git@github\.com:YOUR_USER/REPO\.git +. +.fi +. +.SS "git create" +. +.nf + +$ git create +\.\.\. hardcore creating action \.\.\. +> git remote add origin git@github\.com:YOUR_USER/CURRENT_REPO\.git +. +.fi +. +.SS "git push" +. +.nf + +$ git push origin,staging,qa bert_timeout +> git push origin bert_timeout +> git push staging bert_timeout +> git push qa bert_timeout +. +.fi +. +.SS "git browse" +. +.nf + +$ git browse +> open https://github\.com/YOUR_USER/CURRENT_REPO + +$ git browse \-\- issues +> open https://github\.com/YOUR_USER/CURRENT_REPO/issues + +$ git browse schacon/ticgit +> open https://github\.com/schacon/ticgit + +$ git browse resque +> open https://github\.com/YOUR_USER/resque + +$ git browse resque network +> open https://github\.com/YOUR_USER/resque/network +. +.fi +. +.SS "git compare" +. +.nf + +$ git compare refactor +> open https://github\.com/CURRENT_REPO/compare/refactor + +$ git compare 1\.0\.\.\.1\.1 +> open https://github\.com/CURRENT_REPO/compare/1\.0\.\.\.1\.1 + +$ git compare \-u fix +> (https://github\.com/CURRENT_REPO/compare/fix) + +$ git compare other\-user patch +> open https://github\.com/other\-user/REPO/compare/patch +. +.fi +. +.SS "git help" +. +.nf + +$ git help +> (improved git help) +$ git help hub +> (hub man page) +. +.fi +. +.SH "BUGS" +\fIhttp://github\.com/defunkt/hub/issues\fR +. +.SH "AUTHORS" +\fIhttps://github\.com/defunkt/hub/contributors\fR +. +.SH "SEE ALSO" +git(1), git\-clone(1), git\-remote(1), git\-init(1), \fIhttp://github\.com\fR, \fIhttp://github\.com/defunkt/hub\fR diff --git a/bin/latest-ack b/bin/latest-ack index bbfaac6..2b92af4 100755 --- a/bin/latest-ack +++ b/bin/latest-ack @@ -1,3 +1,4 @@ #!/bin/sh -e -curl http://betterthangrep.com/ack-standalone > ~/bin/ack -chmod +x ~/bin/ack +curl -sLo ~/bin/ack http://betterthangrep.com/ack-standalone +chmod 755 ~/bin/ack +~/bin/ack --version diff --git a/bin/latest-hub b/bin/latest-hub index 167eb73..8f89fbe 100755 --- a/bin/latest-hub +++ b/bin/latest-hub @@ -3,5 +3,6 @@ # Grabs the latest standalone version of Chris Wanstrath's hub # and puts its in your HOME/bin. set -e -curl -o ~/bin/hub http://defunkt.github.com/hub/standalone +curl -sLo ~/bin/hub http://defunkt.github.com/hub/standalone chmod 755 ~/bin/hub +~/bin/hub --version -- 2.43.0