[library-web] get default branch name from repository for modules downloaded using git
- From: Frederic Peters <fpeters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [library-web] get default branch name from repository for modules downloaded using git
- Date: Tue, 16 Jun 2020 21:18:08 +0000 (UTC)
commit 476e16c8eff58745fee667bfbb159db4a3f9e3dc
Author: Frédéric Péters <fpeters 0d be>
Date: Tue Jun 16 23:17:20 2020 +0200
get default branch name from repository for modules downloaded using git
src/lgo.py | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/src/lgo.py b/src/lgo.py
index f6684ca..ac41251 100755
--- a/src/lgo.py
+++ b/src/lgo.py
@@ -309,7 +309,7 @@ class Lgo(App):
branch_name = cgi.parse_qs(parsed_url.query).get('branch')[0]
version_value = cgi.parse_qs(parsed_url.query).get('version')[0]
- if branch_name == 'master':
+ if branch_name in ('main', 'master'):
if not version_value.startswith('.'.join(branch_name.split('-')[1:])):
logging.debug('ignoring git for %s (version != branch)' % module_name)
return
@@ -346,7 +346,13 @@ class Lgo(App):
subp.wait()
if subp.returncode != 0:
if self.latest_stable_release and fake_version_number.startswith(self.latest_stable_release):
- subprocess.Popen(['git', 'checkout', 'master'],
+ try:
+ default_branch = subprocess.check_output(
+ ['git', 'symbolic-ref', '--short', 'refs/remotes/origin/HEAD'],
+ cwd=module_git_clone_dir).decode('ascii').strip()
+ except CommandError:
+ default_branch = 'master'
+ subprocess.Popen(['git', 'checkout', default_branch],
cwd=module_git_clone_dir).wait()
else:
logging.debug('branch do not exist, skipping')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]