diff --git a/repo_resource/common.py b/repo_resource/common.py index 0b20c87..7cbaa1b 100644 --- a/repo_resource/common.py +++ b/repo_resource/common.py @@ -218,7 +218,8 @@ def __init__(self, url, revision='HEAD', name='default.xml', self.__name = name self.__depth = depth self.__version: Version = None - self.__remote = {} + self.__rmt_url = {} + self.__rmt_rev = {} workdir.mkdir(parents=True, exist_ok=True) # gitrepo from https://github.com/grouperenault/gitrepo @@ -240,11 +241,17 @@ def __change_to_workdir(self): def __restore_oldpwd(self): os.chdir(self.__oldpwd) - def __add_remote(self, remote, url): - self.__remote[remote] = url + def __add_remote_url(self, remote, url): + self.__rmt_url[remote] = url + + def __add_remote_rev(self, remote, rev): + self.__rmt_rev[remote] = rev def __remote_url(self, remote): - return self.__remote[remote] + return self.__rmt_url[remote] + + def __remote_rev(self, remote): + return self.__rmt_rev[remote] def init(self): self.__change_to_workdir() @@ -357,17 +364,21 @@ def update_manifest(self, jobs): xml = ET.parse('.repo/manifests/'+self.__name) manifest = xml.getroot() - # Get default values from manifest - defaults = manifest.find('default') - if defaults is not None: - defaultRemote = defaults.get('remote') - defaultBranch = defaults.get('revision') - for r in manifest.findall('remote'): url = r.get('fetch').rstrip('/') if not re.match("[a-zA-Z]+://", url): url = re.sub('/[a-z-.]*$', '/', self.__url) + url - self.__add_remote(r.get('name'), url) + self.__add_remote_url(r.get('name'), url) + rev = r.get('revision') + if rev is not None: + self.__add_remote_rev(r.get('name'), rev) + + # Get default values from manifest + defaults = manifest.find('default') + if defaults is not None: + defaultRemote = defaults.get('remote') + defaultBranch = defaults.get('revision') \ + or self.__remote_rev(defaultRemote) for p in manifest.findall('project'): project = p.get('name')