示例#1
0
文件: notes.py 项目: aspiers/palaver
    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)
示例#2
0
文件: notes.py 项目: aspiers/palaver
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
示例#3
0
文件: notes.py 项目: aspiers/palaver
 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 [])
示例#4
0
文件: notes.py 项目: aspiers/palaver
 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())