Example #1
0
    def add_comment(self, author, state, message):
        """Add a comment to a commit note."""
        comment = Comment(author, state, message)

        (output, err, code) = git.run_cmd('notes', 'append', '--file=-',
                                          self.id, stdin=comment.to_json())
        if code:
            raise git.GitError('"git notes append" failed: %s' % err)
Example #2
0
def iter_notes(git_range, state=None):
    """Iterate over the notes for commits in a given range."""
    (output, err, code) = git.run_cmd('log', '--oneline', '--reverse',
                                      *(LOG_ARGS + [git_range]))
    if code:
        raise git.GitError('"git log" failed: %s' % err)

    commits = [Commit.parse_oneline(l) for l in output.split('\n') if l]
    for commit in commits:
        note = commit.get_note()
        if state:
            states = note.states_by_author().values()
            if state == "none" and states:
                continue
            elif state != "none" and state not in states:
                continue

        yield note
Example #3
0
 def get_note(self):
     """Return the Note associated with this commit,"""
     (output, err, code) = git.run_cmd('notes', 'show', self.id)
     return Note.parse(self, output.split('\n') if not code else [])
Example #4
0
 def get(cls, id):
     """Get a Commit object for a given commit id."""
     (output, err, code) = git.run_cmd('log', '--oneline', '-1', id)
     if code:
         raise git.GitError('"git log" failed: %s' % err)
     return cls.parse_oneline(output.strip())