def get_compare_diff(repo_key, old_branch_or_tag_or_sha, new_branch_or_tag_or_sha): context = request.args.get('context', 3) # NOTE: The `context` parameter is a RestfulGit extension try: context = int(context) except ValueError: raise BadRequest("context was not a valid integer") if context < 0: raise BadRequest("context must not non negative") repo = get_repo(repo_key) old_commit = get_commit_for_refspec(repo, old_branch_or_tag_or_sha) new_commit = get_commit_for_refspec(repo, new_branch_or_tag_or_sha) diff = _get_diff(repo, new_commit, against=old_commit, context_lines=context) return Response(diff.patch, mimetype=mime_types.DIFF)
def get_diff(repo_key, branch_or_tag_or_sha=None): repo = get_repo(repo_key) commit = get_commit_for_refspec(repo, branch_or_tag_or_sha) diff = _get_diff(repo, commit) return Response(diff.patch, mimetype=mime_types.DIFF)