Skip to content

Commit

Permalink
draft: create new draft if none is present
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Aug 22, 2020
1 parent 5585599 commit c81826d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

disable =
bad-continuation, # https://github.com/PyCQA/pylint/issues/2944
fixme,
# TODO(ssbarnea): remove temporary skips adding during initial adoption:
import-error,
missing-class-docstring,
missing-function-docstring,
missing-module-docstring,
too-few-public-methods,
too-many-branches,
wrong-import-order,
22 changes: 22 additions & 0 deletions tender/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ def __init__(self, cfg: Config):
", ".join(self.label_section_map.keys()),
)

# do local cleanups to avoid accidents:

# drop any tags that do not exist on origin
os.system("git fetch --prune origin '+refs/tags/*:refs/tags/*'")

def get_last_unreleased_tag(self) -> Optional[git.Tag]:
for tag in sorted(
self.git.tags, key=lambda t: t.commit.committed_datetime, reverse=True
Expand Down Expand Up @@ -211,12 +216,14 @@ def do_labels(self):
def do_draft(self):
_logger.info("Draft release notes")

release_draft = None
for release in self.repo.get_releases():
print(
f"tag_name={release.tag_name} name={release.title} draft={release.draft}"
f" prerelease={release.prerelease}"
)
if release.draft:
release_draft = release
break

body = "## Changes\n\n"
Expand Down Expand Up @@ -283,6 +290,21 @@ def do_draft(self):
release = None
print(body)

if self.cfg.fix:
if release_draft:
# TODO(ssbarnea): Generate version and set "name"
if release_draft.body == body:
_logger.info("Release body already in-sync, doing nothing.")
return
_logger.info("Updating release body")
release_draft.update_release(name="Draft", message=body, draft=True)
else:
_logger.info("Creating new draft release")
self.repo.create_git_release(
tag="", name="Draft", message=body, draft=True, prerelease=True
)
# set_trace()


def parsed(result):
result.raise_for_status()
Expand Down

0 comments on commit c81826d

Please sign in to comment.