Skip to content

Commit b5bccb3

Browse files
chore(squash): merge fix/ci branch
This commit can be removed once `fix/ci` is merged into `master`.
1 parent a9873d1 commit b5bccb3

File tree

13 files changed

+52
-25
lines changed

13 files changed

+52
-25
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
git config --global user.email "action@github.com"
2828
git config --global user.name "GitHub Action"
2929
./scripts/test
30+
shell: bash
3031
- name: Upload coverage to Codecov
3132
if: runner.os == 'Linux'
3233
uses: codecov/codecov-action@v1.0.3

commitizen/bump.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import re
23
from collections import OrderedDict
34
from itertools import zip_longest
@@ -155,7 +156,9 @@ def update_version_in_files(
155156
"""
156157
# TODO: separate check step and write step
157158
for location in files:
158-
filepath, _, regex = location.partition(":")
159+
drive, tail = os.path.splitdrive(location)
160+
path, _, regex = tail.partition(":")
161+
filepath = drive + path
159162
if not regex:
160163
regex = _version_to_regex(current_version)
161164

commitizen/commands/bump.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
from logging import getLogger
23
from typing import List, Optional
34

@@ -230,9 +231,15 @@ def __call__(self): # noqa: C901
230231
},
231232
)
232233
changelog_cmd()
234+
file_names = []
235+
for file_name in version_files:
236+
drive, tail = os.path.splitdrive(file_name)
237+
path, _, regex = tail.partition(":")
238+
path = drive + path if path != "" else drive + regex
239+
file_names.append(path)
233240
git_add_changelog_and_version_files_command = (
234241
f"git add {changelog_cmd.file_name} "
235-
f"{' '.join(file_name.partition(':')[0] for file_name in version_files)}"
242+
f"{' '.join(name for name in file_names)}"
236243
)
237244
c = cmd.run(git_add_changelog_and_version_files_command)
238245

commitizen/commands/check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def _valid_command_argument(self):
4040
arg is not None
4141
for arg in (self.commit_msg_file, self.commit_msg, self.rev_range)
4242
)
43-
if num_exclusive_args_provided == 0 and not os.isatty(0):
43+
if num_exclusive_args_provided == 0 and not sys.stdin.isatty():
4444
self.commit_msg: Optional[str] = sys.stdin.read()
4545
elif num_exclusive_args_provided != 1:
4646
raise InvalidCommandArgumentError(

scripts/format

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
#!/bin/sh -e
1+
#!/usr/bin/env sh
2+
set -e
23

34
export PREFIX="poetry run python -m "
4-
if [ -d 'venv' ] ; then
5-
export PREFIX="venv/bin/"
6-
fi
75

86
set -x
97

scripts/test

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
#!/bin/sh -e
1+
#!/usr/bin/env sh
2+
set -e
23

3-
export PREFIX="poetry run python -m "
4-
if [ -d 'venv' ] ; then
5-
export PREFIX="venv/bin/"
6-
fi
4+
export PREFIX='poetry run python -m '
5+
export REGEX='^(?![.]|venv).*'
76

87
${PREFIX}pytest -n 3 --cov-report term-missing --cov-report=xml:coverage.xml --cov=commitizen tests/
98
${PREFIX}black commitizen tests --check
109
${PREFIX}isort --check-only commitizen tests
1110
${PREFIX}flake8 commitizen/ tests/
1211
${PREFIX}mypy commitizen/ tests/
13-
${PREFIX}pydocstyle --convention=google --add-ignore=D1,D415
12+
${PREFIX}pydocstyle --convention=google --add-ignore=D1,D415 --match-dir='"${REGEX}"'
1413
${PREFIX}commitizen check --rev-range origin/master..

tests/commands/test_bump_command.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,10 @@ def test_bump_when_version_inconsistent_in_version_files(
302302
tmp_version_file = tmp_commitizen_project.join("__version__.py")
303303
tmp_version_file.write("100.999.10000")
304304
tmp_commitizen_cfg_file = tmp_commitizen_project.join("pyproject.toml")
305+
tmp_version_file_string = str(tmp_version_file).replace("\\", "/")
305306
tmp_commitizen_cfg_file.write(
306307
f"{tmp_commitizen_cfg_file.read()}\n"
307-
f'version_files = ["{str(tmp_version_file)}"]'
308+
f'version_files = ["{tmp_version_file_string}"]'
308309
)
309310

310311
create_file_and_commit("feat: new file")
@@ -323,9 +324,10 @@ def test_bump_files_only(mocker, tmp_commitizen_project):
323324
tmp_version_file = tmp_commitizen_project.join("__version__.py")
324325
tmp_version_file.write("0.1.0")
325326
tmp_commitizen_cfg_file = tmp_commitizen_project.join("pyproject.toml")
327+
tmp_version_file_string = str(tmp_version_file).replace("\\", "/")
326328
tmp_commitizen_cfg_file.write(
327329
f"{tmp_commitizen_cfg_file.read()}\n"
328-
f'version_files = ["{str(tmp_version_file)}"]'
330+
f'version_files = ["{tmp_version_file_string}"]'
329331
)
330332

331333
create_file_and_commit("feat: new user interface")
@@ -355,10 +357,11 @@ def test_bump_local_version(mocker, tmp_commitizen_project):
355357
tmp_version_file = tmp_commitizen_project.join("__version__.py")
356358
tmp_version_file.write("4.5.1+0.1.0")
357359
tmp_commitizen_cfg_file = tmp_commitizen_project.join("pyproject.toml")
360+
tmp_version_file_string = str(tmp_version_file).replace("\\", "/")
358361
tmp_commitizen_cfg_file.write(
359362
f"[tool.commitizen]\n"
360363
'version="4.5.1+0.1.0"\n'
361-
f'version_files = ["{str(tmp_version_file)}"]'
364+
f'version_files = ["{tmp_version_file_string}"]'
362365
)
363366

364367
create_file_and_commit("feat: new user interface")

tests/commands/test_init_command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def test_init_without_setup_pre_commit_hook(tmpdir, mocker, config):
6565

6666
def test_init_when_config_already_exists(config, capsys):
6767
# Set config path
68-
path = "tests/pyproject.toml"
68+
path = os.sep.join(["tests", "pyproject.toml"])
6969
config.add_path(path)
7070

7171
commands.Init(config)()

tests/conftest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def tmp_commitizen_project(tmp_git_project):
2828
def _get_gpg_keyid(signer_mail):
2929
_new_key = cmd.run(f"gpg --list-secret-keys {signer_mail}")
3030
_m = re.search(
31-
rf"[a-zA-Z0-9 \[\]-_]*{os.linesep}[ ]*([0-9A-Za-z]*){os.linesep}[{os.linesep}a-zA-Z0-9 \[\]-_<>@]*",
31+
r"[a-zA-Z0-9 \[\]-_]*\n[ ]*([0-9A-Za-z]*)\n[\na-zA-Z0-9 \[\]-_<>@]*",
3232
_new_key.out,
3333
)
3434
return _m.group(1) if _m else None
@@ -42,7 +42,8 @@ def tmp_commitizen_project_with_gpg(tmp_commitizen_project):
4242
# create a temporary GPGHOME to store a temporary keyring.
4343
# Home path must be less than 104 characters
4444
gpg_home = tempfile.TemporaryDirectory(suffix="_cz")
45-
os.environ["GNUPGHOME"] = gpg_home.name # tempdir = temp keyring
45+
if os.name != "nt":
46+
os.environ["GNUPGHOME"] = gpg_home.name # tempdir = temp keyring
4647

4748
# create a key (a keyring will be generated within GPUPGHOME)
4849
c = cmd.run(

tests/test_bump_create_commit_message.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import sys
23
from pathlib import Path
34
from textwrap import dedent
@@ -55,7 +56,10 @@ def test_bump_pre_commit_changelog(tmp_commitizen_project, mocker, freezer, retr
5556
"""
5657
)
5758
cmd.run("git add -A")
58-
cmd.run("git commit -m 'fix: _test'")
59+
if os.name == "nt":
60+
cmd.run('git commit -m "fix: _test"')
61+
else:
62+
cmd.run("git commit -m 'fix: _test'")
5963
cmd.run("pre-commit install")
6064
cli.main()
6165
# Pre-commit fixed last line adding extra indent and "\" char
@@ -93,7 +97,10 @@ def test_bump_pre_commit_changelog_fails_always(
9397
"""
9498
)
9599
cmd.run("git add -A")
96-
cmd.run("git commit -m 'feat: forbid changelogs'")
100+
if os.name == "nt":
101+
cmd.run('git commit -m "feat: forbid changelogs"')
102+
else:
103+
cmd.run("git commit -m 'feat: forbid changelogs'")
97104
cmd.run("pre-commit install")
98105
with pytest.raises(exceptions.BumpCommitFailedError):
99106
cli.main()

tests/test_bump_update_version_in_files.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
def _copy_sample_file_to_tmpdir(
1616
tmpdir: LocalPath, source_filename: str, dest_filename: str
1717
) -> str:
18-
tmp_file = tmpdir.join(dest_filename)
19-
copyfile(f"{TESTING_FILE_PREFIX}/{source_filename}", str(tmp_file))
20-
return str(tmp_file)
18+
tmp_file = str(tmpdir.join(dest_filename)).replace("\\", "/")
19+
copyfile(f"{TESTING_FILE_PREFIX}/{source_filename}", tmp_file)
20+
return tmp_file
2121

2222

2323
@pytest.fixture(scope="function")

tests/test_cli.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import subprocess
23
import sys
34

@@ -84,6 +85,10 @@ def test_commitizen_debug_excepthook(capsys):
8485
assert "NotAGitProjectError" in str(excinfo.traceback[0])
8586

8687

88+
@pytest.mark.skipif(
89+
os.name == "nt",
90+
reason="`argcomplete` does not support Git Bash on Windows.",
91+
)
8792
def test_argcomplete_activation():
8893
"""
8994
This function is testing the one-time activation of argcomplete for

tests/test_git.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,10 @@ def test_is_staging_clean_when_updating_file(tmp_commitizen_project):
206206

207207
cmd.run("touch test_file")
208208
cmd.run("git add test_file")
209-
cmd.run("git commit -m 'add test_file'")
209+
if os.name == "nt":
210+
cmd.run('git commit -m "add test_file"')
211+
else:
212+
cmd.run("git commit -m 'add test_file'")
210213
cmd.run("echo 'test' > test_file")
211214

212215
assert git.is_staging_clean() is True

0 commit comments

Comments
 (0)