Skip to content

Commit

Permalink
add support for retrieving .diff (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
rajivm authored and cvrebert committed Dec 20, 2013
1 parent 030c2a3 commit 12fa071
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion restfulgit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def _get_diff(repo, commit):
if commit.parents:
diff = repo.diff(commit.parents[0], commit)
diff.find_similar()
else:
else: # NOTE: RestfulGit extension; GitHub gives a 404 in this case
diff = commit.tree.diff_to_tree(swap=True)
return diff

Expand Down Expand Up @@ -659,6 +659,15 @@ def get_repo_list():
return [_convert_repo(repo_key) for repo_key in repositories]


@restfulgit.route('/repos/<repo_key>/commit/<branch_or_tag_or_sha>.diff')
@corsify
def get_repos_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="text/x-diff")


@restfulgit.route('/repos/<repo_key>/branches/')
@corsify
@jsonify
Expand Down

0 comments on commit 12fa071

Please sign in to comment.