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

Changelog: Add missing links #4256

Merged
merged 4 commits into from
Sep 4, 2021
Merged

Conversation

Holzhaus
Copy link
Member

@Holzhaus Holzhaus commented Sep 1, 2021

As requested by @daschuer here: mixxxdj/manual#422 (comment)

Holzhaus added a commit to Holzhaus/manual that referenced this pull request Sep 1, 2021
@Holzhaus
Copy link
Member Author

Holzhaus commented Sep 3, 2021

@daschuer Anything else to do here?

Copy link
Contributor

@Be-ing Be-ing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AUTOMATE ALL THE THINGS

@Holzhaus
Copy link
Member Author

Holzhaus commented Sep 4, 2021

Merge? This just adds missing issue links to the changelog and ensures that missing links are detected beforehand in the future.

Comment on lines 34 to 36
args.file.seek(0)
args.file.write(fixed_changelog)
args.file.truncate()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this cause issues when the changelog is being read from stdin? We should handle this case and just print to stdout in that case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I replaced argparse.FileType with pathlib.Path, so passing - just tries to open a file with that name rather than passing a std stream.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess working around a bug by just removing the feature is a solution...
Since this is not intended to be a super slick tool anyways, I can look past the hacky-ness.

fixed_changelog = add_missing_links(changelog)
if changelog != fixed_changelog:
args.file.seek(0)
args.file.write(fixed_changelog)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we open the file with r+ but then be able to write to it here? Seems like it could cause undefined behavior?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The python docs confuse me here...

https://docs.python.org/3/library/functions.html#open

Character Meaning
'r' open for reading (default)
'w' open for writing, truncating the file first
'x' open for exclusive creation, failing if the file already exists
'a' open for writing, appending to the end of the file if it exists
'b' binary mode
't' text mode (default)
'+' open for updating (reading and writing)

The default mode is 'r' (open for reading text, synonym of 'rt'). Modes 'w+' and 'w+b' open and truncate the file. Modes 'r+' and 'r+b' open the file with no truncation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarified the situation by just opening the file separately for reading and writing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That wouldn't have been necessary, but its much clearer now anways. Thanks

By using `pathlib.Path` instead of `argparse.FileType`, we can restrict
the files to actual paths (not stdin/stdout/stderr) and also get rid of
the ugly seeking/truncating and manual closing of the file.
@Holzhaus Holzhaus merged commit 1d247bd into mixxxdj:2.3 Sep 4, 2021
@Swiftb0y
Copy link
Member

Swiftb0y commented Sep 4, 2021

Sorry forgot to press merge...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants