Skip to content

Commit 10dcc08

Browse files
Merge pull request #118 from redkyn/msg-git-not-installed
Provide informative message if git is not installed
2 parents 2c0c0b3 + 7f0b3e6 commit 10dcc08

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## Devel
22

3+
- Print informative message if `git` is not installed
4+
35
## 1.1.1
46

57
- Fixed `get` failing to clone new repos with error `Remote branch ['master'] not found in upstream origin`

assigner/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from colorlog import ColoredFormatter
88
from requests.exceptions import HTTPError
9+
from git.cmd import GitCommandNotFound
910

1011
from assigner.baserepo import StudentRepo
1112
from assigner.config import config_context
@@ -186,6 +187,8 @@ def main(args=sys.argv[1:]):
186187
raise e
187188
if isinstance(e, KeyError):
188189
logger.error("%s is missing", e)
190+
elif isinstance(e, GitCommandNotFound):
191+
logger.error("git is not installed!")
189192
else:
190193
logger.error(str(e))
191194
raise SystemExit(1) from e

assigner/tests/assigner_test.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from assigner import main, make_parser, subcommands
55
from assigner.tests.utils import AssignerTestCase
66

7+
from git.cmd import GitCommandNotFound
8+
79

810
class MakeParserTestCase(AssignerTestCase):
911
def setUp(self):
@@ -134,6 +136,22 @@ def test_main_logs_keyerror_with_catch(self, mock_logger):
134136
"%s is missing", self.mock_args.run.side_effect
135137
)
136138

139+
@patch("assigner.logger", autospec=True)
140+
def test_main_logs_gitcommandnotfound_with_catch(self, mock_logger):
141+
"""
142+
main should log a GitCommandNotFound with "git is not installed!" when raised.
143+
"""
144+
self.mock_args.tracebacks = False
145+
self.mock_args.run.side_effect = GitCommandNotFound()
146+
try:
147+
main([])
148+
except SystemExit:
149+
pass
150+
151+
mock_logger.error.assert_called_once_with(
152+
"git is not installed!"
153+
)
154+
137155
def test_main_sets_verbosity(self):
138156
"""
139157
main should set verosity and level from args.

0 commit comments

Comments
 (0)