diff --git a/__snapshots__/python.js b/__snapshots__/python.js index 407990e90..8c7ab02f9 100644 --- a/__snapshots__/python.js +++ b/__snapshots__/python.js @@ -24,7 +24,7 @@ exports['Python run creates a release PR 1'] = ` [ "src/version.py", { - "content": "# Copyright 2020 Google LLC\\n#\\n# Licensed under the Apache License, Version 2.0 (the \\"License\\");\\n# you may not use this file except in compliance with the License.\\n# You may obtain a copy of the License at\\n#\\n# https://www.apache.org/licenses/LICENSE-2.0\\n#\\n# Unless required by applicable law or agreed to in writing, software\\n# distributed under the License is distributed on an \\"AS IS\\" BASIS,\\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\\n# See the License for the specific language governing permissions and\\n# limitations under the License.\\n\\n__version__ = \\"0.123.5\\"\\n", + "content": "# Copyright 2020 Google LLC\\n#\\n# Licensed under the Apache License, Version 2.0 (the \\"License\\");\\n# you may not use this file except in compliance with the License.\\n# You may obtain a copy of the License at\\n#\\n# https://www.apache.org/licenses/LICENSE-2.0\\n#\\n# Unless required by applicable law or agreed to in writing, software\\n# distributed under the License is distributed on an \\"AS IS\\" BASIS,\\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\\n# See the License for the specific language governing permissions and\\n# limitations under the License.\\n\\n__version__ = '0.123.5'\\n", "mode": "100644" } ] @@ -57,7 +57,7 @@ exports['Python run creates a release PR relative to a path 1'] = ` [ "projects/python/src/version.py", { - "content": "# Copyright 2020 Google LLC\\n#\\n# Licensed under the Apache License, Version 2.0 (the \\"License\\");\\n# you may not use this file except in compliance with the License.\\n# You may obtain a copy of the License at\\n#\\n# https://www.apache.org/licenses/LICENSE-2.0\\n#\\n# Unless required by applicable law or agreed to in writing, software\\n# distributed under the License is distributed on an \\"AS IS\\" BASIS,\\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\\n# See the License for the specific language governing permissions and\\n# limitations under the License.\\n\\n__version__ = \\"0.123.5\\"\\n", + "content": "# Copyright 2020 Google LLC\\n#\\n# Licensed under the Apache License, Version 2.0 (the \\"License\\");\\n# you may not use this file except in compliance with the License.\\n# You may obtain a copy of the License at\\n#\\n# https://www.apache.org/licenses/LICENSE-2.0\\n#\\n# Unless required by applicable law or agreed to in writing, software\\n# distributed under the License is distributed on an \\"AS IS\\" BASIS,\\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\\n# See the License for the specific language governing permissions and\\n# limitations under the License.\\n\\n__version__ = '0.123.5'\\n", "mode": "100644" } ] diff --git a/__snapshots__/version-py.js b/__snapshots__/version-py.js index ab2a1ff94..d7da84305 100644 --- a/__snapshots__/version-py.js +++ b/__snapshots__/version-py.js @@ -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' ` diff --git a/src/updaters/python/setup-cfg.ts b/src/updaters/python/setup-cfg.ts index b2b1d2adb..bb1f2f823 100644 --- a/src/updaters/python/setup-cfg.ts +++ b/src/updaters/python/setup-cfg.ts @@ -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}` ); } } diff --git a/src/updaters/python/setup-py.ts b/src/updaters/python/setup-py.ts index fb9c0b7c8..bd7fff06f 100644 --- a/src/updaters/python/setup-py.ts +++ b/src/updaters/python/setup-py.ts @@ -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` ); } } diff --git a/src/updaters/python/version-py.ts b/src/updaters/python/version-py.ts index 0e84f017f..ec450623f 100644 --- a/src/updaters/python/version-py.ts +++ b/src/updaters/python/version-py.ts @@ -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` ); } } diff --git a/test/updaters/fixtures/version.py b/test/updaters/fixtures/version.py index 39b40ade4..b6caa68e7 100644 --- a/test/updaters/fixtures/version.py +++ b/test/updaters/fixtures/version.py @@ -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'