Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invoke update-changelog broken #2794

Closed
janosh opened this issue Jan 6, 2023 · 2 comments · Fixed by #2798
Closed

invoke update-changelog broken #2794

janosh opened this issue Jan 6, 2023 · 2 comments · Fixed by #2798

Comments

@janosh
Copy link
Member

janosh commented Jan 6, 2023

@shyuep I was asked to make a new release. No objections from you?

Problem is invoke update-changelog recently started adding a bunch of rST incompatible markdown and HTML into CHANGES.rst. Example:

* PR #2757 from @materialsproject dependabot/pip/phonopy-2.16.3
    Bumps [phonopy](https://phonopy.github.io/phonopy/) from 2.4.2 to 2.16.3.
    [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=phonopy&package-manager=pip&previous-version=2.4.2&new-version=2.16.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
    [//]: # (dependabot-automerge-start)
    [//]: # (dependabot-automerge-end)
    ---
    <details>
    <summary>Dependabot commands and options</summary>
    <br />
    You can trigger Dependabot actions by commenting on this PR:
    - `@dependabot rebase` will rebase this PR
    - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
    - `@dependabot merge` will merge this PR after your CI passes on it
    - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
    - `@dependabot cancel merge` will cancel a previously requested merge and block automerging
    - `@dependabot reopen` will reopen this PR if it is closed
    - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    </details>

Looks like this stems from re-activating dependabot in #2742 as per your request. What's your preference for fixing? We could either convert CHANGES.rst to markdown or modify update_changelog().

pymatgen/tasks.py

Lines 250 to 291 in c1a7f5d

@task
def update_changelog(ctx, version=None, sim=False):
"""
Create a preliminary change log using the git logs.
:param ctx:
"""
version = version or f"{datetime.datetime.now():%Y.%-m.%-d}"
output = subprocess.check_output(["git", "log", "--pretty=format:%s", f"v{CURRENT_VER}..HEAD"])
lines = []
misc = []
for l in output.decode("utf-8").strip().split("\n"):
m = re.match(r"Merge pull request \#(\d+) from (.*)", l)
if m:
pr_number = m.group(1)
contrib, pr_name = m.group(2).split("/", 1)
response = requests.get(f"https://api.github.com/repos/materialsproject/pymatgen/pulls/{pr_number}")
lines.append(f"* PR #{pr_number} from @{contrib} {pr_name}")
json_resp = response.json()
if "body" in json_resp and json_resp["body"]:
for ll in json_resp["body"].split("\n"):
ll = ll.strip()
if ll in ["", "## Summary"]:
continue
elif ll.startswith("## Checklist") or ll.startswith("## TODO"):
break
lines.append(f" {ll}")
misc.append(l)
with open("CHANGES.rst") as f:
contents = f.read()
l = "=========="
toks = contents.split(l)
head = f"\n\nv{version}\n{'-' * (len(version) + 1)}\n"
toks.insert(-1, head + "\n".join(lines))
if not sim:
with open("CHANGES.rst", "w") as f:
f.write(toks[0] + l + "".join(toks[1:]))
ctx.run("open CHANGES.rst")
else:
print(toks[0] + l + "".join(toks[1:]))
print("The following commit messages were not included...")
print("\n".join(misc))

@shyuep
Copy link
Member

shyuep commented Jan 6, 2023

You can delete the dependabot related change log. We don't need to put those in the changelog at all.

@janosh
Copy link
Member Author

janosh commented Jan 6, 2023

I wouldn't want them in there either but there are a dozen of them so don't feel like hand-curating the log. I'll tweak update_changelog() then.

janosh added a commit that referenced this issue Jan 9, 2023
* exclude dependabot PRs in task update_changelog() (closes #2794)

* invoke release

* invoke update-changelog

* remove 'Major Announcement (v2022.0.\*)' section from readme
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants