Commit (git) a specified file

    This method does the same than a ::

        $ git commit -a "message"

    Keyword Arguments:
        :filename: (str) -- name of the file to commit

    Returns:
        <nothing>
543301
def commit(filename):
    
    try:
        repo = Repo()
        # gitcmd = repo.git
        # gitcmd.commit(filename)
        index = repo.index
        index.commit("Updated file: {0}".format(filename))
    except Exception as e:
        print("exception while commit: %s" % e.message)
69498
def get_files_in_commit(git_folder, commit_id="HEAD"):
    
    repo = Repo(str(git_folder))
    output = repo.git.diff("--name-only", commit_id+"^", commit_id)
    return output.splitlines()
845923
public function getCommitMessage($file = null)
    {
        if ($file) {
            $hash = null;
            $message = file_get_contents($file);
        } else {
            list($hash, $message) = explode(PHP_EOL, $this->getLastCommitMessage(), 2);
        }

        return new CommitMessage($message, $hash);
    }
1181938
function(commit, line) {
    if (line.indexOf('    ') !== 0) return false;
    line = line.trim();
    if (commit.message && line) commit.message += '\n'
    commit.message += line;
    return true;
  }
587003
def commit_new_version(version: str):
    

    check_repo()
    commit_message = config.get('semantic_release', 'commit_message')
    message = '{0}\n\n{1}'.format(version, commit_message)
    repo.git.add(config.get('semantic_release', 'version_variable').split(':')[0])
    return repo.git.commit(m=message, author="semantic-release <semantic-release>")
649890
def get_commits_and_names_iter(self, path):
        '''
        
        '''
        log_result = self.git.log(
            '--pretty=%H',
            '--follow',
            '--name-only',
            '--',
            path).splitlines()

        for commit_sha, _, filename in grouper(log_result, 3):
            yield self.repo.commit(commit_sha), filename
197199
def get_commit(self, commit_id: str) -> Commit:
        
        return Commit(self.repo.commit(commit_id), self.path, self.main_branch)
1061207
def checkout_commit(repo_path: str,
                    commit: Any = None) -> None:  # pylint:disable=redefined-outer-name
    
    commit = commit or 'master'
    run_command(cmd='git checkout {}'.format(commit), data=None, location=repo_path, chw=True)
1245549
def save(self, filename=None):
        
        if not filename:
            filename = self.filename
        if not filename:
            raise Exception("No filename specified")
        if filename[-4:].lower() == '.bz2':
            f = bz2.BZ2File(filename,'wb')
            f.write(self.xmlstring().encode('utf-8'))
            f.close()
        elif filename[-3:].lower() == '.gz':
            f = gzip.GzipFile(filename,'wb') #pylint: disable=redefined-variable-type
            f.write(self.xmlstring().encode('utf-8'))
            f.close()
        else:
            f = io.open(filename,'w',encoding='utf-8')
            f.write(self.xmlstring())
            f.close()
593459
def get_commits_modified_file(self, filepath: str) -> List[str]:
        
        path = str(Path(filepath))

        commits = []
        try:
            commits = self.git.log("--follow", "--format=%H", path).split('\n')
        except GitCommandError:
            logger.debug("Could not find information of file %s", path)

        return commits
884427
def git_commit(targets, message, force=False, sign=False):
    
    root = get_root()
    target_paths = []
    for t in targets:
        target_paths.append(os.path.join(root, t))

    with chdir(root):
        result = run_command('git add{} {}'.format(' -f' if force else '', ' '.join(target_paths)))
        if result.code != 0:
            return result

        return run_command('git commit{} -m "{}"'.format(' -S' if sign else '', message))
95778
def commit(experiment_name, time):
    
    try:
        sh.git.commit('-a',
                m='"auto commit tracked files for new experiment: {} on {}"'.format(experiment_name, time),
                allow_empty=True
            )
        commit_hash = sh.git('rev-parse', 'HEAD').strip()
        return commit_hash
    except:
        return '<Unable to commit>'
588625
def process_file(vcs, commit, force, gitlint_config, file_data):
    
    filename, extra_data = file_data

    if force:
        modified_lines = None
    else:
        modified_lines = vcs.modified_lines(
            filename, extra_data, commit=commit)
    result = linters.lint(filename, modified_lines, gitlint_config)
    result = result[filename]

    return filename, result
189009
def get_commit_command(self, message, author=None):
        """"""
        command = ['git']
        if author:
            command.extend(('-c', 'user.name=%s' % author.name))
            command.extend(('-c', 'user.email=%s' % author.email))
        command.append('commit')
        command.append('--all')
        command.append('--message')
        command.append(message)
        return command
239147
def approval_filename
      parts = [ example, *example.example_group.parent_groups ].map do |ex|
        Git::Approvals::Utils.filenamify ex.description
      end
      File.join parts.to_a.reverse
    end
1070517
def get_commit_message(self, commit_sha):
        
        cmd = ["git", "show", "-s", "--format=%B", commit_sha]
        output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
        message = output.strip().decode("utf-8")
        if self.config["fix_commit_msg"]:
            return message.replace("#", "GH-")
        else:
            return message
92782
def is_git_file(cls, path, name):
        """"""
        os.chdir(path)
        p = subprocess.Popen(['git', 'ls-files', '--error-unmatch', name],
                             stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        p.wait()
        return p.returncode == 0