Repository: redkyn/assigner

Issue:
Assigner doesn't provide a helpful message if git is not installed
...instead, assigner yells at you in an unsettling manner!

I will provide an example later today.

Discussion:

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index acbcc3b..7159c48 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,7 @@
 ## Devel
 
+- Print informative message if `git` is not installed
+
 ## 1.1.1
 
 - Fixed `get` failing to clone new repos with error `Remote branch ['master'] not found in upstream origin`
diff --git a/assigner/__init__.py b/assigner/__init__.py
index 1099245..b19db23 100755
--- a/assigner/__init__.py
+++ b/assigner/__init__.py
@@ -6,6 +6,7 @@ import sys
 
 from colorlog import ColoredFormatter
 from requests.exceptions import HTTPError
+from git.cmd import GitCommandNotFound
 
 from assigner.baserepo import StudentRepo
 from assigner.config import config_context
@@ -186,6 +187,8 @@ def main(args=sys.argv[1:]):
             raise e
         if isinstance(e, KeyError):
             logger.error("%s is missing", e)
+        elif isinstance(e, GitCommandNotFound):
+            logger.error("git is not installed!")
         else:
             logger.error(str(e))
         raise SystemExit(1) from e


Test patch:
diff --git a/assigner/tests/assigner_test.py b/assigner/tests/assigner_test.py
index 2811a70..771e70e 100644
--- a/assigner/tests/assigner_test.py
+++ b/assigner/tests/assigner_test.py
@@ -4,6 +4,8 @@ from unittest.mock import patch
 from assigner import main, make_parser, subcommands
 from assigner.tests.utils import AssignerTestCase
 
+from git.cmd import GitCommandNotFound
+
 
 class MakeParserTestCase(AssignerTestCase):
     def setUp(self):
@@ -134,6 +136,22 @@ class MainTestCase(AssignerTestCase):
             "%s is missing", self.mock_args.run.side_effect
         )
 
+    @patch("assigner.logger", autospec=True)
+    def test_main_logs_gitcommandnotfound_with_catch(self, mock_logger):
+        """
+        main should log a GitCommandNotFound with "git is not installed!" when raised.
+        """
+        self.mock_args.tracebacks = False
+        self.mock_args.run.side_effect = GitCommandNotFound()
+        try:
+            main([])
+        except SystemExit:
+            pass
+
+        mock_logger.error.assert_called_once_with(
+            "git is not installed!"
+        )
+
     def test_main_sets_verbosity(self):
         """
         main should set verosity and level from args.