Enable gerrit/gitlab/github refspecs

By default git only fetches references under the refs/heads/ tree,
this patch adds support to kas to enable you to specify references
outside of the ref/heads tree.  This is useful as it allows you to
use uncommitted gerrit patchsets, Gitlab merge requests or github
pull requests that live under refs/changes/, refs/merge-requests
and refs/pull as the reference for a repo allowing the use of
in development changes.  When a refsepc is defined that starts
with refs/ an additional git fetch operation is preformed on the
repo to explicitly fetch the reference given so it can be checked
out for use.

Signed-off-by: Drew Reed <drew.reed@arm.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
Drew Reed
2021-07-06 15:12:51 +02:00
committed by Jan Kiszka
parent 635b1023a1
commit 6b65de3e2f
3 changed files with 58 additions and 7 deletions

View File

@@ -63,3 +63,27 @@ def test_refspec_switch(changedir, tmpdir):
fail=False, liveupdate=False)
assert rc == 0
assert output.strip() == '907816a5c4094b59a36aec12226e71c461c05b77'
def test_refspec_absolute(changedir, tmpdir):
"""
Test that the local git clone works when a absolute refspec
is givvn.
"""
tdir = str(tmpdir.mkdir('test_refspec_absolute'))
shutil.rmtree(tdir, ignore_errors=True)
shutil.copytree('tests/test_refspec', tdir)
os.chdir(tdir)
kas.kas(['shell', 'test3.yml', '-c', 'true'])
(rc, output) = run_cmd(['git', 'symbolic-ref', '-q', 'HEAD'],
cwd='kas_abs', fail=False, liveupdate=False)
assert rc != 0
assert output.strip() == ''
(rc, output_kas_abs) = run_cmd(['git', 'rev-parse', 'HEAD'],
cwd='kas_abs', fail=False, liveupdate=False)
assert rc == 0
(rc, output_kas_rel) = run_cmd(['git', 'rev-parse', 'HEAD'],
cwd='kas_rel', fail=False, liveupdate=False)
assert rc == 0
assert output_kas_abs.strip() == output_kas_rel.strip()

View File

@@ -0,0 +1,13 @@
header:
version: 8
repos:
this:
kas_abs:
url: https://github.com/siemens/kas.git
refspec: refs/heads/master
kas_rel:
url: https://github.com/siemens/kas.git
refspec: master