feat(source): checkout via reference
- provide source tool ability to checkout commit hash Change-Id: Ic3b101a4877fd89516df8c4814802780a15e2461
This commit is contained in:
parent
1f78038efe
commit
16b14169f8
|
@ -23,12 +23,14 @@ class GitTestCase(unittest.TestCase):
|
||||||
|
|
||||||
SOURCE_UTILS_LOCATION = 'armada.utils.source'
|
SOURCE_UTILS_LOCATION = 'armada.utils.source'
|
||||||
|
|
||||||
|
@mock.patch('armada.utils.source.Git')
|
||||||
@mock.patch('armada.utils.source.tempfile')
|
@mock.patch('armada.utils.source.tempfile')
|
||||||
@mock.patch('armada.utils.source.Repo')
|
@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_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'
|
url = 'http://github.com/att-comdev/armada'
|
||||||
|
|
||||||
dir = source.git_clone(url)
|
dir = source.git_clone(url)
|
||||||
|
|
||||||
self.assertIsNotNone(dir)
|
self.assertIsNotNone(dir)
|
||||||
|
|
|
@ -20,6 +20,7 @@ import tarfile
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from git import Repo
|
from git import Repo
|
||||||
|
from git import Git
|
||||||
|
|
||||||
from ..exceptions import source_exceptions
|
from ..exceptions import source_exceptions
|
||||||
|
|
||||||
|
@ -38,7 +39,9 @@ def git_clone(repo_url, branch='master'):
|
||||||
_tmp_dir = tempfile.mkdtemp(prefix='armada')
|
_tmp_dir = tempfile.mkdtemp(prefix='armada')
|
||||||
|
|
||||||
try:
|
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:
|
except Exception:
|
||||||
raise source_exceptions.GitLocationException(repo_url)
|
raise source_exceptions.GitLocationException(repo_url)
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ data:
|
||||||
type: git
|
type: git
|
||||||
location: https://github.com/gardlt/hello-world-chart
|
location: https://github.com/gardlt/hello-world-chart
|
||||||
subpath: .
|
subpath: .
|
||||||
reference: master
|
reference: 87aad18f7d8c6a1a08f3adc8866efd33bee6aa52
|
||||||
dependencies: []
|
dependencies: []
|
||||||
---
|
---
|
||||||
schema: armada/Chart/v1
|
schema: armada/Chart/v1
|
||||||
|
|
Loading…
Reference in New Issue