feat(source): checkout via reference

- provide source tool ability to checkout commit hash

Change-Id: Ic3b101a4877fd89516df8c4814802780a15e2461
This commit is contained in:
gardlt 2017-09-15 20:55:25 +00:00
parent 1f78038efe
commit 16b14169f8
3 changed files with 9 additions and 4 deletions

View File

@ -23,12 +23,14 @@ class GitTestCase(unittest.TestCase):
SOURCE_UTILS_LOCATION = 'armada.utils.source'
@mock.patch('armada.utils.source.Git')
@mock.patch('armada.utils.source.tempfile')
@mock.patch('armada.utils.source.Repo')
def test_git_clone_good_url(self, mock_git_repo, mock_temp):
def test_git_clone_good_url(self, mock_git_repo, mock_temp, mock_git_lib):
mock_temp.mkdtemp.return_value = '/tmp/armada'
mock_git_repo.clone_from.return_value = "Repository"
mock_git_lib.checkout.return_value = "Repository"
url = 'http://github.com/att-comdev/armada'
dir = source.git_clone(url)
self.assertIsNotNone(dir)

View File

@ -20,6 +20,7 @@ import tarfile
import tempfile
from git import Repo
from git import Git
from ..exceptions import source_exceptions
@ -38,7 +39,9 @@ def git_clone(repo_url, branch='master'):
_tmp_dir = tempfile.mkdtemp(prefix='armada')
try:
Repo.clone_from(repo_url, _tmp_dir, **{'branch': branch})
repo = Repo.clone_from(repo_url, _tmp_dir, **{'branch': 'master'})
g = Git(repo.working_dir)
g.checkout(branch)
except Exception:
raise source_exceptions.GitLocationException(repo_url)

View File

@ -13,7 +13,7 @@ data:
type: git
location: https://github.com/gardlt/hello-world-chart
subpath: .
reference: master
reference: 87aad18f7d8c6a1a08f3adc8866efd33bee6aa52
dependencies: []
---
schema: armada/Chart/v1