def diff(repository, ref, from_ref=None, **kwargs): # TODO: add merge_base support _diff = {} ref = ref.strip() sha = _resolve_version(repository, ref) if not sha: raise JagareError("%s...%s" % (from_ref, ref)) commit = get_commit_by_sha(repository, sha) from_commit = None if from_ref: from_ref = from_ref.strip() from_sha = _resolve_version(repository, from_ref) if not from_sha: raise JagareError("%s...%s" % (from_ref, ref)) from_commit = get_commit_by_sha(repository, from_sha) # get pygit2 diff if from_commit: diff, _diff['old_sha'] = diff_commits(repository, commit, from_commit, **kwargs) else: diff, _diff['old_sha'] = diff_commit(repository, commit, **kwargs) _diff['new_sha'] = commit.hex _diff['diff'] = diff return _diff
def sha(self, rev='HEAD'): return _resolve_version(self.repository, rev)
def resolve_commit(self, version): version = version.strip() return _resolve_version(self.repository, version)