[asterisk-commits] Encoding, branch tracking, and other sundries (repotools[master])
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Apr 5 14:23:54 CDT 2016
Joshua Colp has submitted this change and it was merged.
Change subject: Encoding, branch tracking, and other sundries
......................................................................
Encoding, branch tracking, and other sundries
Fixed a unicode problem when processing the release summary (credit to
mmichelson for this fix)
The branch tracking was a bit off. The script was creating release branches off
whatever the current branch was. On initial clone it's set to master, which
worked fine for non asterisk releases like libpri. However for asterisk these
need to be the mainline branches. Updated to first switch to the mainline branch
before creating the release branch.
Added a progress bar when processing the git log file. Depending on the number
of entries this can take a while.
Set migration log level to warning, so it wasn't so spammy when debugging.
When processing the ChangeLog if it already exists it gets deleted. However,
this was happening too early and couldn't be found when it needed to be. Moved
the removal of the ChangeLog to after it has been copied.
Change-Id: I51aaddedcbf856a8c95a122cb61aaf8f87c3d02c
---
M digium_git.py
M mkrelease.py
M release_summary.py
A utils.py
M version_parser.py
5 files changed, 82 insertions(+), 22 deletions(-)
Approvals:
Joshua Colp: Looks good to me, approved; Verified
diff --git a/digium_git.py b/digium_git.py
index 5001bf3..ac8a837 100644
--- a/digium_git.py
+++ b/digium_git.py
@@ -12,6 +12,7 @@
import logging
import os
+import utils
from progressbar import ProgressBar
from digium_commits import DigiumCommitMessageParser
@@ -158,14 +159,16 @@
return GitProgressBar() if self.show_progress else None
- def _set_tracking(self, branch, tracking):
+ def _set_tracking(self, branch, tracking=None):
"""Set up tracking on a branch"""
if branch.tracking_branch():
return True
try:
- branch.set_tracking_branch(self.repo.remotes.origin.refs[tracking])
+ if tracking is None:
+ tracking = self.repo.remotes.origin.refs[branch.name]
+ branch.set_tracking_branch(tracking)
return True
except:
# No remote branch, so branch is probably a new local branch.
@@ -181,7 +184,7 @@
LOGGER.debug("Pushing branch {0} to remote".format(self.current_branch))
self.repo.remotes.origin.push(refspec='refs/heads/{0}:refs/heads/{1}'.format(
self.current_branch, self.current_branch), progress=self.progress)
- self._set_tracking(self.repo.heads[self.current_branch], self.current_branch)
+ self._set_tracking(self.repo.heads[self.current_branch])
def branch_exists(self, name):
@@ -247,15 +250,23 @@
return
try:
+ # See if the branch is on the remote
+ tracking = self.repo.remotes.origin.refs[name]
+ except:
+ tracking = 'HEAD'
+
+ try:
branch = self.repo.heads[name]
except:
LOGGER.debug("Creating local branch {0}".format(name))
- branch = self.repo.create_head(name)
+ branch = self.repo.create_head(name, tracking)
+
+ # Track the branch if possible
+ tracked = self._set_tracking(branch, tracking)
branch.checkout()
- # Set up tracking if in the remote
- if self._set_tracking(branch, name):
+ if tracked:
self.repo.remotes.origin.pull()
LOGGER.debug("Local branch set to {0}".format(name))
@@ -291,9 +302,10 @@
"""
digium_commits = []
- for git_commit in git_commits:
+ for git_commit in utils.track_progress(git_commits):
digium_commit = self._convert_git_to_digium_commit(git_commit)
digium_commits.append(digium_commit)
+
return digium_commits
diff --git a/mkrelease.py b/mkrelease.py
index b780602..d83897e 100755
--- a/mkrelease.py
+++ b/mkrelease.py
@@ -29,6 +29,8 @@
# modules so we don't see so many messages
logging.getLogger("requests").setLevel(logging.WARNING)
logging.getLogger("urllib3").setLevel(logging.WARNING)
+# Same for the migration stuff
+logging.getLogger("alembic").setLevel(logging.WARNING)
# The one and only Gerrit/Git server.
@@ -132,10 +134,11 @@
return repo
-def prepare_branch(repo):
+def prepare_branch(options, repo):
"""Prepare the branch that the release will be made from
Keyword Arguments:
+ options - Parsed command line arguments
repo - The prepared repo
"""
global branch
@@ -151,11 +154,18 @@
branch = '{0}.{1}'.format(version_object.major,
version_object.minor)
+ if options.project.lower() != 'asterisk':
+ # Assume non asterisk project release branches are off of master
+ mainline = 'master'
+
if repo.branch_exists(branch):
LOGGER.debug("Branch {0} exists already".format(branch))
else:
LOGGER.debug("Branch {0} does not exist".format(branch))
prompt_to_continue()
+ # Switch to the mainline branch first that way the new release
+ # branch is created off of that
+ repo.checkout(mainline)
repo.checkout(branch)
@@ -262,10 +272,6 @@
old_log_path = os.path.join(options.local_root, options.project,
'OldLog')
- if os.path.isfile(change_log_path):
- LOGGER.debug("Removing old ChangeLog")
- os.unlink(change_log_path)
-
# Check out the start tag and copy over its ChangeLog
LOGGER.debug("Getting previous change log from '{0}'".format(start_version))
repo.checkout(start_version)
@@ -275,6 +281,10 @@
# Switch back to our branch
LOGGER.debug("Switching back to {0}".format(branch))
repo.checkout(branch)
+
+ if os.path.isfile(change_log_path):
+ LOGGER.debug("Removing old ChangeLog")
+ os.unlink(change_log_path)
# Actually create the new ChangeLog
with open(change_log_path, 'w') as c_file:
@@ -577,7 +587,9 @@
extract_archive()
pull_meta_files(release_name)
- exec_prep_tarball(release_name)
+ if options.project.lower() == 'asterisk':
+ # Only download Asterisk docs for Asterisk releases
+ exec_prep_tarball(release_name)
final_archive = create_archive(release_name)
create_hashes(final_archive)
@@ -642,7 +654,7 @@
# the environment, and calculate what it is we are trying to create.
setup_options(options)
repo = prepare_repo(options)
- prepare_branch(repo)
+ prepare_branch(options, repo)
extract_tags(options, repo)
if repo.tag_exists(version):
diff --git a/release_summary.py b/release_summary.py
index b39f264..8ff09a1 100755
--- a/release_summary.py
+++ b/release_summary.py
@@ -391,7 +391,7 @@
log_message.raw.hexsha))
msg_link("[{0}]".format(log_message.raw.hexsha[:10]))
msg_li.raw_text("{0} {1} -- {2}".format(
- str(msg_link), unicode(coders).encode('utf-8'), log_message.get_commit_summary()))
+ str(msg_link), coders, log_message.get_commit_summary()))
else:
msg_li("{0} -- {1}".format(coders,
log_message.get_commit_summary()))
@@ -602,7 +602,7 @@
for log_message in self.misc_commits:
coders = [coder.full_name or coder.username for coder in
log_message.get_coders()]
- coders = ','.join(coders)
+ coders = ','.join(coders).encode('utf-8')
coder_row = misc_table.tr()
rev_column = coder_row.td()
if log_message.raw:
diff --git a/utils.py b/utils.py
new file mode 100644
index 0000000..7121618
--- /dev/null
+++ b/utils.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+"""Shared utilities.
+
+A collection of common functionality.
+
+Copyright (C) 2016, Digium, Inc.
+Kevin Harwell <kharwell at digium.com>
+"""
+
+import logging
+
+from progressbar import ProgressBar
+
+LOGGER = logging.getLogger(__name__)
+
+
+def track_progress(iterable):
+ """Track the progress of processed items
+
+ Keyword Arguments:
+ iterable: a list of items to process
+ """
+
+ # Only show progress if in debug mode
+ if not logging.getLogger().isEnabledFor(logging.DEBUG):
+ for j in iterable:
+ yield j
+ return
+
+ size = len(iterable)
+
+ LOGGER.debug("Tracking progress on {0} items".format(size))
+
+ pbar = ProgressBar(size).start()
+ for i, j in enumerate(iterable):
+ yield j
+ pbar.update(i + 1)
+ pbar.finish()
diff --git a/version_parser.py b/version_parser.py
index 7e2c5ac..3a6188b 100644
--- a/version_parser.py
+++ b/version_parser.py
@@ -52,13 +52,11 @@
ver_modifiers = version_parts[len(version_parts) - 1].split('-')
version_parts[len(version_parts) - 1] = ver_modifiers.pop(0)
- # Parse out the major/minor digits, handling the case where we have
- # a leading '1' digit
- start_index = 0
- major = int(version_parts[start_index])
- minor = int(version_parts[start_index + 1])
+ # Parse out the major/minor digits
+ major = int(version_parts[0])
+ minor = int(version_parts[1])
if len(version_parts) > 2:
- patch = int(version_parts[start_index + 2])
+ patch = int(version_parts[2])
else:
patch = -1
--
To view, visit https://gerrit.asterisk.org/2519
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I51aaddedcbf856a8c95a122cb61aaf8f87c3d02c
Gerrit-PatchSet: 1
Gerrit-Project: repotools
Gerrit-Branch: master
Gerrit-Owner: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
More information about the asterisk-commits
mailing list