Repository: Stratoscale/skipper

Issue:
can't build skipper (skipper build cmd) with v2.0.0 and v2.0.1
See $TOPIC.

I get:

# skipper build
```python
WARNING:root:*** Uncommitted changes present - Build container version might be outdated ***
[skipper] Building image: assisted-service-build
INFO:skipper:Building image: assisted-service-build
Traceback (most recent call last):
  File "/usr/local/bin/skipper", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/skipper/main.py", line 12, in main
    return_code = cli.cli(
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/skipper/cli.py", line 117, in build
    fqdn_image = image + ':' + tag
TypeError: can only concatenate str (not "bytes") to str
```

Comments:

Patch:
diff --git a/.gitignore b/.gitignore
index 089cb66..281342a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,6 @@
+.vscode
+**__pycache__**
+**.pytest_cache**
 *.egg-info
 *.pyc
 .cache
diff --git a/skipper/git.py b/skipper/git.py
index daa02c6..5098114 100644
--- a/skipper/git.py
+++ b/skipper/git.py
@@ -16,7 +16,7 @@ def get_hash(short=False):
     if uncommitted_changes():
         logging.warning("*** Uncommitted changes present - Build container version might be outdated ***")
 
-    return subprocess.check_output(git_command).strip()
+    return subprocess.check_output(git_command).strip().decode('utf-8')
 
 
 def uncommitted_changes():


Test patch:
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 63011ed..9ac3b6b 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -1680,7 +1680,7 @@ class TestCLI(unittest.TestCase):
     @mock.patch('builtins.open', mock.MagicMock(create=True))
     @mock.patch('os.path.exists', mock.MagicMock(autospec=True, return_value=True))
     @mock.patch('yaml.safe_load', mock.MagicMock(autospec=True, return_value=SKIPPER_CONF_WITH_GIT_REV))
-    @mock.patch('subprocess.check_output', mock.MagicMock(autospec=True, return_value='1234567\n'))
+    @mock.patch('subprocess.check_output', mock.MagicMock(autospec=True, return_value=b'1234567\n'))
     @mock.patch('skipper.git.uncommitted_changes', mock.MagicMock(return_value=True))
     @mock.patch('skipper.runner.run', autospec=True)
     def test_run_with_config_including_git_revision_with_uncommitted_changes(self, skipper_runner_run_mock):
@@ -1701,7 +1701,7 @@ class TestCLI(unittest.TestCase):
     @mock.patch('builtins.open', mock.MagicMock(create=True))
     @mock.patch('os.path.exists', mock.MagicMock(autospec=True, return_value=True))
     @mock.patch('yaml.safe_load', mock.MagicMock(autospec=True, return_value=SKIPPER_CONF_WITH_GIT_REV))
-    @mock.patch('subprocess.check_output', mock.MagicMock(autospec=True, return_value='1234567\n'))
+    @mock.patch('subprocess.check_output', mock.MagicMock(autospec=True, return_value=b'1234567\n'))
     @mock.patch('skipper.git.uncommitted_changes', mock.MagicMock(return_value=False))
     @mock.patch('skipper.runner.run', autospec=True)
     def test_run_with_config_including_git_revision_without_uncommitted_changes(self, skipper_runner_run_mock):
diff --git a/tests/test_git.py b/tests/test_git.py
index a7c4703..2eed711 100644
--- a/tests/test_git.py
+++ b/tests/test_git.py
@@ -3,8 +3,8 @@ import mock
 from skipper import git
 
 
-GIT_HASH_FULL = '00efe974e3cf18c3493f110f5aeda04ff78b125f'
-GIT_HASH_SHORT = '00efe97'
+GIT_HASH_FULL = b'00efe974e3cf18c3493f110f5aeda04ff78b125f'
+GIT_HASH_SHORT = b'00efe97'
 
 
 class TestGit(unittest.TestCase):
@@ -14,7 +14,7 @@ class TestGit(unittest.TestCase):
         git_hash = git.get_hash()
         exists_mock.assert_called_once_with('.git')
         check_output_mock.assert_called_once_with(['git', 'rev-parse', 'HEAD'])
-        self.assertEqual(git_hash, GIT_HASH_FULL)
+        self.assertEqual(git_hash, GIT_HASH_FULL.decode('utf-8'))
 
     @mock.patch('subprocess.check_output', return_value=GIT_HASH_FULL)
     @mock.patch('os.path.exists', return_value=True)
@@ -22,7 +22,7 @@ class TestGit(unittest.TestCase):
         git_hash = git.get_hash(short=False)
         exists_mock.assert_called_once_with('.git')
         check_output_mock.assert_called_once_with(['git', 'rev-parse', 'HEAD'])
-        self.assertEqual(git_hash, GIT_HASH_FULL)
+        self.assertEqual(git_hash, GIT_HASH_FULL.decode('utf-8'))
 
     @mock.patch('subprocess.check_output', return_value=GIT_HASH_SHORT)
     @mock.patch('os.path.exists', return_value=True)
@@ -30,7 +30,7 @@ class TestGit(unittest.TestCase):
         git_hash = git.get_hash(short=True)
         exists_mock.assert_called_once_with('.git')
         check_output_mock.assert_called_once_with(['git', 'rev-parse', '--short', 'HEAD'])
-        self.assertEqual(git_hash, GIT_HASH_SHORT)
+        self.assertEqual(git_hash, GIT_HASH_SHORT.decode('utf-8'))
 
     @mock.patch('subprocess.check_output')
     @mock.patch('os.path.exists', return_value=False)