DEFAULT_CHROOT_NAME = "gentoo"
DEFAULT_CHROOT_USER = "root"
+GITWEB_RE = r'^((file://|git\+ssh://[A-Za-z.:@]+)?/srv/git|git://[A-Za-z.:@]+)'
+GITWEB_URL = 'http://git/gitweb.cgi'
+
ENV_CATEGORY = "CATEGORY"
ENV_CHROOT = "CHROOT_NAME"
ENV_CHROOT_USER = "CHROOT_USER"
msg = ('The head commit {commit} is already tagged with {tag}.\n'
'Call this script without --tag-from-debian-changelog '
'to release the ebuild file.')
- msg = msg.format(commit=current_commit.hexsha[0:7], tag=new_tag)
+ msg = msg.format(commit=format_commit(current_commit), tag=new_tag)
else:
msg = ('The head commit {commit} is already tagged: {tags}\n'
'The script expects a commit without additional tags.')
- msg = msg.format(commit=current_commit.hexsha[0:7],
+ msg = msg.format(commit=format_commit(current_commit),
tags=" ".join(tags))
logger.error(msg)
sys.exit(1)
if len(remote_tag) > 0:
msg = ('Tag {tag} was already created for commit '
'{commit}.'.format(tag=new_tag,
- commit=remote_tag[0].commit.hexsha[0:7]))
+ commit=format_commit(remote_tag[0].commit)))
logger.error(msg + resolve_existing_msg)
sys.exit(1)
logger.info("Tagging commit {commit} with {tag}"
- "...".format(commit=current_commit.hexsha[0:7], tag=new_tag))
+ "...".format(commit=format_commit(current_commit),
+ tag=new_tag))
repo.git.tag(new_tag)
+def format_commit(commit):
+ """Create a human readable string for a given git commit."""
+ remote_url = commit.repo.config_reader().get('remote "origin"', "url")
+ weburl = re.sub(GITWEB_RE, GITWEB_URL, remote_url)
+ weburl += "/commit/" + commit.hexsha[0:7]
+ return commit.hexsha[0:7] + ' ( ' + weburl + ' )'
+
def get_latest_tag(logger):
"""Get the tag name for the branch head commit.
The function will fail if the branch head commit is not tagged or has
current_commit = repo.commit(repo.active_branch)
tags = [t.name for t in repo.tags if t.commit == current_commit]
if len(tags) == 0:
- logger.error('No tag found for commit {commit}.\nHave you tagged '
- 'your release?'.format(commit=current_commit.hexsha[0:7]))
+ logger.error('No tag found for commit {commit}.\nHave you tagged your '
+ 'release?'.format(commit=format_commit(current_commit)))
sys.exit(1)
if len(tags) > 1:
msg = ('More than one tag found for commit {commit}: {tags}\n'
'The script expects exactly one tag.')
- logger.error(msg.format(commit=current_commit.hexsha[0:7],
+ logger.error(msg.format(commit=format_commit(current_commit),
tags=" ".join(tags)))
sys.exit(1)
tag = tags[0]