mirror of
https://git.yoctoproject.org/poky
synced 2026-09-20 03:49:32 +02:00
bitbake: fetch2/git: ensure the unpacked origin remote points upstream
If you're interested in using the checked out repository for development (e.g. in OE with devtool) then you ideally want the origin remote to point to the repository it was fetched from, so just set that after cloning. (As part of this I did a minor refactor so we have one function to generate the repository URL, which was already in two places.) Fixes [YOCTO #7756]. (Bitbake rev: 80ecd1c54d4c748cee3a7ce0d64013a346e7671e) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
1dc2ee903b
commit
f5a87b4707
@@ -178,11 +178,6 @@ class Git(FetchMethod):
|
|||||||
def download(self, ud, d):
|
def download(self, ud, d):
|
||||||
"""Fetch url"""
|
"""Fetch url"""
|
||||||
|
|
||||||
if ud.user:
|
|
||||||
username = ud.user + '@'
|
|
||||||
else:
|
|
||||||
username = ""
|
|
||||||
|
|
||||||
ud.repochanged = not os.path.exists(ud.fullmirror)
|
ud.repochanged = not os.path.exists(ud.fullmirror)
|
||||||
|
|
||||||
# If the checkout doesn't exist and the mirror tarball does, extract it
|
# If the checkout doesn't exist and the mirror tarball does, extract it
|
||||||
@@ -191,7 +186,7 @@ class Git(FetchMethod):
|
|||||||
os.chdir(ud.clonedir)
|
os.chdir(ud.clonedir)
|
||||||
runfetchcmd("tar -xzf %s" % (ud.fullmirror), d)
|
runfetchcmd("tar -xzf %s" % (ud.fullmirror), d)
|
||||||
|
|
||||||
repourl = "%s://%s%s%s" % (ud.proto, username, ud.host, ud.path)
|
repourl = self._get_repo_url(ud)
|
||||||
|
|
||||||
# If the repo still doesn't exist, fallback to cloning it
|
# If the repo still doesn't exist, fallback to cloning it
|
||||||
if not os.path.exists(ud.clonedir):
|
if not os.path.exists(ud.clonedir):
|
||||||
@@ -277,8 +272,10 @@ class Git(FetchMethod):
|
|||||||
clonedir = indirectiondir
|
clonedir = indirectiondir
|
||||||
|
|
||||||
runfetchcmd("%s clone %s %s/ %s" % (ud.basecmd, cloneflags, clonedir, destdir), d)
|
runfetchcmd("%s clone %s %s/ %s" % (ud.basecmd, cloneflags, clonedir, destdir), d)
|
||||||
|
os.chdir(destdir)
|
||||||
|
repourl = self._get_repo_url(ud)
|
||||||
|
runfetchcmd("%s remote set-url origin %s" % (ud.basecmd, repourl), d)
|
||||||
if not ud.nocheckout:
|
if not ud.nocheckout:
|
||||||
os.chdir(destdir)
|
|
||||||
if subdir != "":
|
if subdir != "":
|
||||||
runfetchcmd("%s read-tree %s%s" % (ud.basecmd, ud.revisions[ud.names[0]], readpathspec), d)
|
runfetchcmd("%s read-tree %s%s" % (ud.basecmd, ud.revisions[ud.names[0]], readpathspec), d)
|
||||||
runfetchcmd("%s checkout-index -q -f -a" % ud.basecmd, d)
|
runfetchcmd("%s checkout-index -q -f -a" % ud.basecmd, d)
|
||||||
@@ -312,6 +309,16 @@ class Git(FetchMethod):
|
|||||||
raise bb.fetch2.FetchError("The command '%s' gave output with more then 1 line unexpectedly, output: '%s'" % (cmd, output))
|
raise bb.fetch2.FetchError("The command '%s' gave output with more then 1 line unexpectedly, output: '%s'" % (cmd, output))
|
||||||
return output.split()[0] != "0"
|
return output.split()[0] != "0"
|
||||||
|
|
||||||
|
def _get_repo_url(self, ud):
|
||||||
|
"""
|
||||||
|
Return the repository URL
|
||||||
|
"""
|
||||||
|
if ud.user:
|
||||||
|
username = ud.user + '@'
|
||||||
|
else:
|
||||||
|
username = ""
|
||||||
|
return "%s://%s%s%s" % (ud.proto, username, ud.host, ud.path)
|
||||||
|
|
||||||
def _revision_key(self, ud, d, name):
|
def _revision_key(self, ud, d, name):
|
||||||
"""
|
"""
|
||||||
Return a unique key for the url
|
Return a unique key for the url
|
||||||
@@ -322,13 +329,9 @@ class Git(FetchMethod):
|
|||||||
"""
|
"""
|
||||||
Run git ls-remote with the specified search string
|
Run git ls-remote with the specified search string
|
||||||
"""
|
"""
|
||||||
if ud.user:
|
repourl = self._get_repo_url(ud)
|
||||||
username = ud.user + '@'
|
cmd = "%s ls-remote %s %s" % \
|
||||||
else:
|
(ud.basecmd, repourl, search)
|
||||||
username = ""
|
|
||||||
|
|
||||||
cmd = "%s ls-remote %s://%s%s%s %s" % \
|
|
||||||
(ud.basecmd, ud.proto, username, ud.host, ud.path, search)
|
|
||||||
if ud.proto.lower() != 'file':
|
if ud.proto.lower() != 'file':
|
||||||
bb.fetch2.check_network_access(d, cmd)
|
bb.fetch2.check_network_access(d, cmd)
|
||||||
output = runfetchcmd(cmd, d, True)
|
output = runfetchcmd(cmd, d, True)
|
||||||
|
|||||||
Reference in New Issue
Block a user