mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 20:59:01 +02:00
utils.py: fix checkout_repo when no HEAD
Fixed: $ git clone <url> warning: remote HEAD refers to nonexistent ref, unable to checkout. $ git rev-parse HEAD HEAD fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' Catch the error and avoid that. And use "git reset --hard" to replace of "git reset --hard HEAD", HEAD is default for git reset, so they are the same, but the later one reports error when remote HEAD doesn't exist: $ git reset --hard HEAD fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree. [snip] $ git reset --hard No errors. Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
parent
635187b594
commit
a661ebe6ac
|
@ -217,17 +217,25 @@ def checkout_repo(repodir, commit, logger, force=False):
|
||||||
if force:
|
if force:
|
||||||
currentref = ''
|
currentref = ''
|
||||||
else:
|
else:
|
||||||
currentref = runcmd("git rev-parse HEAD", repodir, logger=logger).strip()
|
try:
|
||||||
|
# The "git rev-parse HEAD" returns "fatal: ambiguous argument 'HEAD'"
|
||||||
|
# when a repo is unable to check out after git clone:
|
||||||
|
# git clone <url>
|
||||||
|
# warning: remote HEAD refers to nonexistent ref, unable to checkout.
|
||||||
|
# So check and avoid that
|
||||||
|
currentref = runcmd("git rev-parse HEAD", repodir, logger=logger).strip()
|
||||||
|
except Exception as esc:
|
||||||
|
logger.warn(esc)
|
||||||
|
currentref = ''
|
||||||
if currentref != commit:
|
if currentref != commit:
|
||||||
# Reset in case there are added but uncommitted changes
|
# Reset in case there are added but uncommitted changes
|
||||||
runcmd("git reset --hard HEAD", repodir, logger=logger)
|
runcmd("git reset --hard", repodir, logger=logger)
|
||||||
# Drop any untracked files in case these cause problems (either because
|
# Drop any untracked files in case these cause problems (either because
|
||||||
# they will exist in the revision we're checking out, or will otherwise
|
# they will exist in the revision we're checking out, or will otherwise
|
||||||
# interfere with operation, e.g. stale pyc files)
|
# interfere with operation, e.g. stale pyc files)
|
||||||
runcmd("git clean -qdfx", repodir, logger=logger)
|
runcmd("git clean -qdfx", repodir, logger=logger)
|
||||||
# Now check out the revision
|
# Now check out the revision
|
||||||
runcmd("git checkout %s" % commit,
|
runcmd("git checkout %s" % commit, repodir, logger=logger)
|
||||||
repodir, logger=logger)
|
|
||||||
|
|
||||||
def checkout_layer_branch(layerbranch, repodir, logger=None):
|
def checkout_layer_branch(layerbranch, repodir, logger=None):
|
||||||
branchname = layerbranch.branch.name
|
branchname = layerbranch.branch.name
|
||||||
|
|
Loading…
Reference in New Issue
Block a user