Skip to content

Commit

Permalink
fix problems in bootstrap_history probably due to refactoring
Browse files Browse the repository at this point in the history
should work out of the box now, also minor rewording
  • Loading branch information
martenson committed May 16, 2016
1 parent ddc2412 commit 661e008
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions scripts/bootstrap_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
.. github_links
"""

ANNOUNCE_TEMPLATE = string.Template("""
Expand Down Expand Up @@ -180,10 +181,10 @@
- [ ] **Create Release Notes**
- [ ] Review merged PRs and ensure they all milestones attached. [Link](https://github.com/galaxyproject/galaxy/pulls?q=is%3Apr+is%3Amerged+no%3Amilestone)
- [ ] Review merged PRs and ensure they all have a milestones attached. [Link](https://github.com/galaxyproject/galaxy/pulls?q=is%3Apr+is%3Amerged+no%3Amilestone)
- [ ] Checkout release branch
git checkout $version -b ${version}_release_notes
git checkout release_${version} -b ${version}_release_notes
- [ ] Check for obvious missing metadata in release PRs
make release-check-metadata RELEASE_CURR=${version}
Expand Down Expand Up @@ -287,7 +288,7 @@ def do_release(argv):
open(next_release_file, "w").write(next_announce.encode("utf-8"))
releases_index = _release_file("index.rst")
releases_index_contents = open(releases_index, "r").read()
releases_index_contents = releases_index_contents.replace(".. annoucements\n", ".. annoucements\n" + next_version + "_announce\n" )
releases_index_contents = releases_index_contents.replace(".. annoucements\n", ".. annoucements\n " + next_version + "_announce\n" )
with open(releases_index, "w") as f:
f.write(releases_index_contents)

Expand Down Expand Up @@ -337,10 +338,14 @@ def check_blocking_issues(argv):


def _pr_to_str(pr):
if isinstance(pr, basestring):
return pr
return "PR #%s (%s) %s" % (pr.number, pr.title, pr.html_url)


def _issue_to_str(pr):
if isinstance(pr, basestring):
return pr
return "Issue #%s (%s) %s" % (pr.number, pr.title, pr.html_url)


Expand Down Expand Up @@ -390,6 +395,7 @@ def _get_prs(release_name, state="closed"):


def main(argv):
# print argv
if requests is None:
raise Exception("Requests library not found, please pip install requests")
github = _github_client()
Expand Down Expand Up @@ -479,7 +485,7 @@ def extend(from_str, line, source=history):
)
to_doc += "\n`Pull Request {0}`_".format(pull_request)
if github:
_text_target(github, pull_request)
text_target = _text_target(github, pull_request)
elif ident.startswith("issue"):
issue = ident[len("issue"):]
text = ".. _Issue {0}: {1}/issues/{0}".format(issue, PROJECT_URL)
Expand All @@ -492,17 +498,28 @@ def extend(from_str, line, source=history):
to_doc += "{0}_".format(short_rev)

to_doc = wrap(to_doc)
history = extend(".. %s\n" % text_target, to_doc)
# print history
history = extend(".. %s\n" % text_target, to_doc, history)
# print history
open(history_path, "w").write(history.encode("utf-8"))


def _text_target(github, pull_request):
labels = []
pr_number = None
if isinstance(pull_request, basestring):
pr_number = pull_request
else:
pr_number = pull_request.number

try:
labels = github.issues.labels.list_by_issue(int(pull_request.number), user=PROJECT_OWNER, repo=PROJECT_NAME)
labels = github.issues.labels.list_by_issue(int(pr_number), user=PROJECT_OWNER, repo=PROJECT_NAME)
except Exception as e:
print e
is_bug = is_enhancement = is_feature = is_minor = is_major = is_merge = is_small_enhancement = False
if len(labels) == 0:
print 'No labels found for %s' % pr_number
return None
for label in labels:
label_name = label.name.lower()
if label_name == "minor":
Expand Down Expand Up @@ -542,7 +559,7 @@ def _text_target(github, pull_request):
elif is_bug:
text_target = "bug"
else:
print "Logic problem, cannot determine section for %s" % pull_request
print "Logic problem, cannot determine section for %s" % _pr_to_str(pull_request)
text_target = None
return text_target

Expand Down

0 comments on commit 661e008

Please sign in to comment.