liberate the ruby-git's private command method with a few tweaks
332309
def native(cmd, opts = [], chdir = true, redirect = '', &block)
      validate

      ENV['GIT_DIR'] = @git_dir
      ENV['GIT_INDEX_FILE'] = @git_index_file
      ENV['GIT_WORK_TREE'] = @git_work_dir
      path = @git_work_dir || @git_dir || @path

      opts = [opts].flatten.map {|s| escape(s) }.join(' ')
      git_cmd = "git #{cmd} #{opts} #{redirect} 2>&1"

      out = nil
      if chdir && (Dir.getwd != path)
        Dir.chdir(path) { out = run_command(git_cmd, &block) }
      else
        out = run_command(git_cmd, &block)
      end

      if @logger
        @logger.info(git_cmd)
        @logger.debug(out)
      end

      if $?.exitstatus > 0
        if $?.exitstatus == 1 && out == ''
          return ''
        end
        raise Git::CommandFailed.new(git_cmd, $?.exitstatus, out.to_s)
      end
      out
    end
1317716
function(cb) {
            git(repoDir, ['status'], function(err, stdout, stderr) {
                if (err) {
                    log.warn('git status failed on ' + repoDir + ":", err.msg);
                    var indexFile = path.join(repoDir, '.git', 'index');
                    path.exists(indexFile, function(exists) {
                        if (exists) {
                            fs.unlink(indexFile, function(err) {
                                if (err) {
                                    log.warn('removing file ' + indexFile + ' failed with:', err);
                                }
                                else {
                                    log.info('removed index file: ' + indexFile);
                                }
                                cb(err, {status: {stdout: stdout, stderr: stderr}, removeIndex: 'remove git index ' + indexFile + ', result ' + err});
                            });
                            return;
                        }
                        log.warn('No index file ' + indexFile);
                        cb(err, {status: {stdout: stdout, stderr: stderr}, removeIndex: 'no index present'});
                    });
                    return;
                }
                cb(null, {status: {stdout: stdout, stderr: stderr}});
            });
        }
623587
def run!
      git  = nil
      path = nil

      return show_usage() if ARGV.length < 1
      name = ARGV.shift() if ARGV.first[ 0 ] != '-'

      opts = GetoptLong.new(
        [ '--help',    '-h',       GetoptLong::NO_ARGUMENT       ],
        [ '--version', '-v', '-V', GetoptLong::NO_ARGUMENT       ],
        [ '--path',    '-p',       GetoptLong::REQUIRED_ARGUMENT ],
        [ '--from',    '-f',       GetoptLong::REQUIRED_ARGUMENT ],
        [ '--git',     '-g',       GetoptLong::REQUIRED_ARGUMENT ],
      )

      silence_stream( $stderr ) do
        begin
          opts.each do | opt, arg |
            case opt
              when '--help'
                return show_usage()
              when '--version'
                return show_version()
              when '--path'
                path = arg
              when '--from', '--git'
                git = arg
            end
          end

        rescue GetoptLong::InvalidOption, GetoptLong::MissingArgument => e
          return usage_and_warning( e.message )

        end
      end

      unless path.nil? || git.nil?
        return usage_and_warning( 'Use the --path OR --from arguments, but not both' )
      end

      git ||= 'git@github.com:LoyaltyNZ/service_shell.git'

      name = ARGV.shift() if name.nil?
      return show_usage() if name.nil?

      return usage_and_warning( "Unexpected extra arguments were given" ) if ARGV.count > 0
      return usage_and_warning( "SERVICE_NAME must match #{ NAME_REGEX.inspect }" ) if naughty_name?( name )
      return usage_and_warning( "'#{ name }' already exists" ) if File.exist?( "./#{ name }" )

      return create_service( name, git, path )
    end
61132
function gitPush () {
      var branch = options.branch;
      var withForce = options.force ? ' --force ' : '';

      if (options.remoteBranch) branch += ':' + options.remoteBranch;

      log.subhead('Pushing ' + options.branch + ' to ' + options.remote + withForce);
      execWrap('git push ' + withForce + remoteName + ' ' + branch, false, true);

      if (options.tag) {
        execWrap('git push ' + remoteName + ' ' + options.tag);
      }
    }
632102
def delete!(allow_secret = false)
      GPGME::Ctx.new do |ctx|
        ctx.delete_key self, allow_secret
      end
    end
315759
def remote(self, *args):
        
        log_path = args[0]
        ChangeLog_txt = args[1]
        lib_path = args[2]
        PACKAGES_TXT = args[3]
        CHECKSUMS_MD5 = args[4]
        FILELIST_TXT = args[5]
        repo = args[6]

        if self.checks_logs(log_path, ChangeLog_txt):
            # remove old files
            self.file_remove(log_path, ChangeLog_txt.split("/")[-1])
            self.file_remove(lib_path, PACKAGES_TXT.split("/")[-1])
            self.file_remove(lib_path, CHECKSUMS_MD5.split("/")[-1])
            self.file_remove(lib_path, FILELIST_TXT.split("/")[-1])
            if repo == "slack":
                dirs = ["core/", "extra/", "pasture/"]
                for d in dirs:
                    self.file_remove(lib_path + d, "PACKAGES.TXT")
                    self.file_remove(lib_path + d, "CHECKSUMS.md5")
                self.down(lib_path + "core/", PACKAGES_TXT, repo)
                self.down(lib_path + "core/", CHECKSUMS_MD5, repo)
                self.down(lib_path + "extra/", self.EXTRA, repo)
                self.down(lib_path + "extra/", self.EXT_CHECKSUMS, repo)
                if slack_ver() != "14.0":  # no pasture/ folder for 14.0 version
                    self.down(lib_path + "pasture/", self.PASTURE, repo)
                    self.down(lib_path + "pasture/", self.PAS_CHECKSUMS, repo)
            # download new files
            if repo != "slack":
                self.down(lib_path, PACKAGES_TXT, repo)
                self.down(lib_path, CHECKSUMS_MD5, repo)
            self.down(lib_path, FILELIST_TXT, repo)
            self.down(log_path, ChangeLog_txt, repo)
162788
def clean_stale_refs(self):
        '''
        
        '''
        cleaned = []
        cmd_str = 'git remote prune origin'

        # Attempt to force all output to plain ascii english, which is what some parsing code
        # may expect.
        # According to stackoverflow (http://goo.gl/l74GC8), we are setting LANGUAGE as well
        # just to be sure.
        env = os.environ.copy()
        env[b"LANGUAGE"] = b"C"
        env[b"LC_ALL"] = b"C"

        cmd = subprocess.Popen(
            shlex.split(cmd_str),
            close_fds=not salt.utils.platform.is_windows(),
            cwd=os.path.dirname(self.gitdir),
            env=env,
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT)
        output = cmd.communicate()[0]
        if six.PY3:
            output = output.decode(__salt_system_encoding__)
        if cmd.returncode != 0:
            log.warning(
                'Failed to prune stale branches for %s remote \'%s\'. '
                'Output from \'%s\' follows:\n%s',
                self.role, self.id, cmd_str, output
            )
        else:
            marker = ' * [pruned] '
            for line in salt.utils.itertools.split(output, '\n'):
                if line.startswith(marker):
                    cleaned.append(line[len(marker):].strip())
            if cleaned:
                log.debug(
                    '%s pruned the following stale refs: %s',
                    self.role, ', '.join(cleaned)
                )
        return cleaned
87317
def remove(self, repo):
        
        rem_repo = False
        with open(self.custom_repo_file, "w") as repos:
            for line in self.custom_repositories_list.splitlines():
                repo_name = line.split()[0]
                if repo_name != repo:
                    repos.write(line + "\n")
                else:
                    print("\nRepository '{0}' successfully "
                          "removed\n".format(repo))
                    rem_repo = True
            repos.close()
        if not rem_repo:
            print("\nRepository '{0}' doesn't exist\n".format(repo))
        raise SystemExit()
541084
def _run_git_command(cls, cmd, **opts):
        

        if '_bare' in opts:
            _copts = []
            del opts['_bare']
        else:
            _copts = ['-c', 'core.quotepath=false', ]
        safe_call = False
        if '_safe' in opts:
            #no exc on failure
            del opts['_safe']
            safe_call = True

        _str_cmd = False
        if isinstance(cmd, basestring):
            cmd = [cmd]
            _str_cmd = True

        gitenv = os.environ
        # need to clean fix GIT_DIR !
        if 'GIT_DIR' in gitenv:
            del gitenv['GIT_DIR']
        gitenv['GIT_CONFIG_NOGLOBAL'] = '1'

        _git_path = settings.GIT_EXECUTABLE_PATH
        cmd = [_git_path] + _copts + cmd
        if _str_cmd:
            cmd = ' '.join(cmd)
        try:
            _opts = dict(
                env=gitenv,
                shell=False,
            )
            _opts.update(opts)
            p = subprocessio.SubprocessIOChunker(cmd, **_opts)
        except (EnvironmentError, OSError), err:
            tb_err = ("Couldn't run git command (%s).\n"
                      "Original error was:%s\n" % (cmd, err))
            if safe_call:
                return '', err
            else:
                raise RepositoryError(tb_err)

        return ''.join(p.output), ''.join(p.error)
850168
function clone(git_url, git_ref, clone_dir){
    
    var needsGitCheckout = !!git_ref;
    if (!shell.which('git')) {
        return Q.reject(new Error('"git" command line tool is not installed: make sure it is accessible on your PATH.'));
    }

    // If no clone_dir is specified, create a tmp dir which git will clone into.
    var tmp_dir = clone_dir;
    if(!tmp_dir){
        tmp_dir = path.join(os.tmpdir(), 'git', String((new Date()).valueOf()));
    }
    shell.rm('-rf', tmp_dir);
    shell.mkdir('-p', tmp_dir);
    
    var cloneArgs = ['clone'];
    if(!needsGitCheckout) {
        // only get depth of 1 if there is no branch/commit specified
        cloneArgs.push('--depth=1');
    }
    cloneArgs.push(git_url, tmp_dir);
    return superspawn.spawn('git', cloneArgs)
    .then(function() {
        if (needsGitCheckout){
            return superspawn.spawn('git', ['checkout', git_ref], {
                cwd: tmp_dir
            });
        }
    })
    .then(function(){
        events.emit('log', 'Repository "' + git_url + '" checked out to git ref "' + (git_ref || 'master') + '".');
        return tmp_dir;
    })
    .fail(function (err) {
        shell.rm('-rf', tmp_dir);
        return Q.reject(err);
    });
}
785709
def temporarily_write_git_hash(git_hash, filename=os.path.join('sockeye', 'git_version.py')):
    """"""
    content = """
# This file is automatically generated in setup.py
git_hash = "%s"
""" % git_hash
    if os.path.exists(filename):
        raise RuntimeError("%s already exists, will not overwrite" % filename)
    with open(filename, "w") as out:
        out.write(content)
    try:
        yield
    except:
        raise
    finally:
        os.remove(filename)
48482
def remove
      key = shift_argument
      if key.nil? || key.empty?
        error("Usage: heroku keys:remove KEY\nMust specify KEY to remove.")
      end
      validate_arguments!

      action("Removing #{key} SSH key") do
        api.delete_key(key)
      end
    end
516879
function (next) {
            // silence terminal output to prevent leaking sensitive information
            config.silent = true;

            pushd(WIKI_GIT_PATH);
            exec('git add --all');
            exec('git commit -m "[auto] ' + WIKI_VERSION + '"');
            exec('git push origin master', function (code) {
                popd();
                next(code);
            });
        }
210429
def hide_methods(mod, except_defaults, *stuff)
      options = stuff.last.is_a?(Hash) ? stuff.pop : {}
      include_ancestors  = options.fetch(:ancestors){false}
      except             = Array(options.fetch(:except){except_defaults})
      protect            = Array(options[:protect])
      except_methods     = collect_methods(true, *except)
      protect_methods    = collect_methods(true, *protect)
      methods_to_hide    = collect_methods(include_ancestors, *stuff)
      (methods_to_hide - except_methods).each do |method_name|
        mod.module_eval do 
          next unless method_defined?(method_name)
          if protect_methods.include?(method_name)
            protected method_name
          else
            private method_name
          end
        end
      end
    end
203436
def call(release, _options = {})
      Dir.chdir(release.build_path.to_s) do
        @pattern.each do |pattern|
          Dir.glob(pattern).each do |file|
            clean_path(release, file)
          end
        end
      end
    end
902040
def clone(cls, srcpath, destpath, encoding='utf-8'):
        """"""
        cmd = [GIT, 'clone', '--quiet', '--bare', srcpath, destpath]
        subprocess.check_call(cmd)
        return cls(destpath, encoding)
872821
def uninstall():
    """"""
    ret, git_dir, _ = run("git rev-parse --show-toplevel")
    if ret != 0:
        click.echo(
            "ERROR: Please run from within a GIT repository.",
            file=sys.stderr)
        raise click.Abort
    git_dir = git_dir[0]

    hooks_dir = os.path.join(git_dir, HOOK_PATH)

    for hook in HOOKS:
        hook_path = os.path.join(hooks_dir, hook)
        if os.path.exists(hook_path):
            os.remove(hook_path)
    return True