Skip to content

Commit aca827a

Browse files
authored
Merge pull request #63 from Woile/Woile-patch-1
ci: new github actions
2 parents c100cf7 + fb46792 commit aca827a

File tree

3 files changed

+57
-24
lines changed

3 files changed

+57
-24
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Python package
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
strategy:
10+
max-parallel: 4
11+
matrix:
12+
python-version: [3.6, 3.7, 3.8]
13+
14+
steps:
15+
- uses: actions/checkout@v1
16+
- name: Set up Python ${{ matrix.python-version }}
17+
uses: actions/setup-python@v1
18+
with:
19+
python-version: ${{ matrix.python-version }}
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --pre -U poetry
23+
poetry --version
24+
poetry install
25+
- name: Run tests
26+
run: |
27+
./scripts/test

commitizen/commands/commit.py

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,33 @@ def __init__(self, config: dict, arguments: dict):
2323
self.arguments = arguments
2424
self.temp_file: str = os.path.join(tempfile.gettempdir(), "cz.commit.backup")
2525

26+
def read_backup_message(self) -> str:
27+
# Check the commit backup file exists
28+
if not os.path.isfile(self.temp_file):
29+
out.error("No commit backup found")
30+
raise SystemExit(NO_COMMIT_BACKUP)
31+
32+
# Read commit message from backup
33+
with open(self.temp_file, "r") as f:
34+
return f.read().strip()
35+
36+
def prompt_commit_questions(self) -> str:
37+
# Prompt user for the commit message
38+
cz = self.cz
39+
questions = cz.questions()
40+
try:
41+
answers = questionary.prompt(questions, style=cz.style)
42+
except ValueError as err:
43+
root_err = err.__context__
44+
if isinstance(root_err, CzException):
45+
out.error(root_err.__str__())
46+
raise SystemExit(CUSTOM_ERROR)
47+
raise err
48+
49+
if not answers:
50+
raise SystemExit(NO_ANSWERS)
51+
return cz.message(answers)
52+
2653
def __call__(self):
2754
if git.is_staging_clean():
2855
out.write("No files added to staging!")
@@ -31,30 +58,9 @@ def __call__(self):
3158
retry: bool = self.arguments.get("retry")
3259

3360
if retry:
34-
# Check the commit backup file exists
35-
if not os.path.isfile(self.temp_file):
36-
out.error("No commit backup found")
37-
raise SystemExit(NO_COMMIT_BACKUP)
38-
39-
# Read commit message from backup
40-
with open(self.temp_file, "r") as f:
41-
m = f.read().strip()
61+
m = self.read_backup_message()
4262
else:
43-
# Prompt user for the commit message
44-
cz = self.cz
45-
questions = cz.questions()
46-
try:
47-
answers = questionary.prompt(questions, style=cz.style)
48-
except ValueError as err:
49-
root_err = err.__context__
50-
if isinstance(root_err, CzException):
51-
out.error(root_err.__str__())
52-
raise SystemExit(CUSTOM_ERROR)
53-
raise err
54-
55-
if not answers:
56-
raise SystemExit(NO_ANSWERS)
57-
m = cz.message(answers)
63+
m = self.prompt_commit_questions()
5864

5965
out.info(f"\n{m}\n")
6066
c = git.commit(m)

scripts/test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export PREFIX=""
1+
export PREFIX="poetry run python -m "
22
if [ -d 'venv' ] ; then
33
export PREFIX="venv/bin/"
44
fi

0 commit comments

Comments
 (0)