Skip to content

Commit

Permalink
added non-github api for retrieving tag by name /repos/{repo_key}/tag…
Browse files Browse the repository at this point in the history
…s/{tag_name} (#59)
  • Loading branch information
rajivm authored and cvrebert committed Dec 17, 2013
1 parent 28c86fe commit b8e3c2d
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion restfulgit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,9 +685,32 @@ def get_tags(repo_key):
"url": url_for('.get_repos_commit', _external=True,
repo_key=repo_key, branch_or_tag_or_sha=tag.get_object().hex),
},
"url": url_for('.get_repos_tag', _external=True,
repo_key=repo_key, tag_name=tag.shorthand),
} for tag in tags]


@restfulgit.route('/repos/<repo_key>/tags/<tag_name>/')
@corsify
@jsonify
def get_repos_tag(repo_key, tag_name):
repo = _get_repo(repo_key)
tag = _lookup_ref(repo, TAG_REF_PREFIX + tag_name)
if tag is None:
raise NotFound("tag not found")
result = {
"name": tag.shorthand,
"commit": _repos_convert_commit(repo_key, repo, tag.get_object()),
"url": url_for('.get_repos_tag', _external=True,
repo_key=repo_key, tag_name=tag.shorthand),
}
# simple tag
if tag.target != tag.get_object().oid:
tag_obj = repo[tag.target]
result['tag'] = _convert_tag(repo_key, repo, tag_obj)
return result


@restfulgit.route('/repos/<repo_key>/branches/')
@corsify
@jsonify
Expand All @@ -704,7 +727,6 @@ def get_branches(repo_key):
} for branch in branches]



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

0 comments on commit b8e3c2d

Please sign in to comment.