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

fix: do not change format of Python version files #782

Merged
merged 2 commits into from
Feb 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions __snapshots__/python.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion __snapshots__/version-py.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ exports['version.py updateContent updates version in version.py 1'] = `
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.6.0"
__version__ = '0.6.0'

`
4 changes: 2 additions & 2 deletions src/updaters/python/setup-cfg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export class SetupCfg implements Update {
}
updateContent(content: string): string {
return content.replace(
/version ?= ?[0-9]+\.[0-9]+\.[0-9](-\w+)?/,
`version = ${this.version}`
/(version ?= ?)[0-9]+\.[0-9]+\.[0-9](?:-\w+)?/,
`$1${this.version}`
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice!

);
}
}
4 changes: 2 additions & 2 deletions src/updaters/python/setup-py.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export class SetupPy implements Update {
}
updateContent(content: string): string {
return content.replace(
/version ?= ?["'][0-9]+\.[0-9]+\.[0-9](-\w+)?["']/,
`version = "${this.version}"`
/(version ?= ?["'])[0-9]+\.[0-9]+\.[0-9](?:-\w+)?(["'])/,
`$1${this.version}$2`
);
}
}
4 changes: 2 additions & 2 deletions src/updaters/python/version-py.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export class VersionPy implements Update {
}
updateContent(content: string): string {
return content.replace(
/__version__ ?= ?["'][0-9]+\.[0-9]+\.[0-9](-\w+)?["']/,
`__version__ = "${this.version}"`
/(__version__ ?= ?["'])[0-9]+\.[0-9]+\.[0-9](?:-\w+)?(["'])/,
`$1${this.version}$2`
);
}
}
2 changes: 1 addition & 1 deletion test/updaters/fixtures/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.5.0"
__version__ = '0.5.0'
Copy link
Collaborator

Choose a reason for hiding this comment

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

why did this and the snapshot need to change? in any case I think black uses "?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed this to have at least one test that would not pass before the fix.
I don't know why the snapshot needed to change. I guess whatever files are involved in it had a different formatting