Skip to content

Commit

Permalink
bugfix: checks fail when revision set in remote
Browse files Browse the repository at this point in the history
Checks fail when default revision is set in remote instead of default element.

Signed-off-by: David Rozé <[email protected]>
  • Loading branch information
david-baylibre committed Feb 28, 2024
1 parent 57dc969 commit 1c91dc5
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions repo_resource/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 1c91dc5

Please sign in to comment.