git: allow an empty refspec even when using version control

If no refspec was given just take the default we get after clone.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
This commit is contained in:
Henning Schild 2018-01-02 13:00:33 +01:00 committed by Daniel Wagner
parent 62cf4fb0eb
commit ce02354627
2 changed files with 8 additions and 2 deletions

View File

@ -321,7 +321,9 @@ Configuration reference
are performed. are performed.
* ``refspec``: string [optional] * ``refspec``: string [optional]
The refspec that should be used. Required if an ``url`` was specified. The refspec that should be used. If ``url`` was specified bot no
``refspec`` the revision you get depends on the defaults of the version
control system used.
* ``path``: string [optional] * ``path``: string [optional]
The path where the repository is stored. The path where the repository is stored.

View File

@ -177,6 +177,10 @@ def _repo_fetch_async(config, repo):
logging.info('Repository %s cloned', repo.name) logging.info('Repository %s cloned', repo.name)
return retc return retc
# take what came out of clone and stick to that forever
if repo.refspec is None:
return 0
# Does refspec exist in the current repository? # Does refspec exist in the current repository?
(retc, output) = yield from run_cmd_async(['git', (retc, output) = yield from run_cmd_async(['git',
'cat-file', '-t', 'cat-file', '-t',
@ -229,7 +233,7 @@ def repo_checkout(config, repo):
""" """
Checks out the correct revision of the repo. Checks out the correct revision of the repo.
""" """
if repo.git_operation_disabled: if repo.git_operation_disabled or repo.refspec is None:
return return
# Check if repos is dirty # Check if repos is dirty