Update make-index for Zuul v3
With Zuul v3, we do no have remotes anymore in git, so adapt script to run locally and in Zuul correctly. Change-Id: Ib141605164fce55fd782466f31c780c5286db6bd
This commit is contained in:
parent
07da459413
commit
824df0036b
24
make-index
24
make-index
@ -17,6 +17,10 @@
|
|||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
# For running locally
|
||||||
|
using_zuul = False
|
||||||
|
remote = "remotes/origin/"
|
||||||
|
|
||||||
def run_local(cmd, cwd='.', env={}):
|
def run_local(cmd, cwd='.', env={}):
|
||||||
print "Running:", cmd
|
print "Running:", cmd
|
||||||
newenv = os.environ
|
newenv = os.environ
|
||||||
@ -31,7 +35,8 @@ def git_branches():
|
|||||||
r, branch_list = run_local(['git', 'branch', '-a'])
|
r, branch_list = run_local(['git', 'branch', '-a'])
|
||||||
for branch in branch_list.split("\n"):
|
for branch in branch_list.split("\n"):
|
||||||
branch = branch.strip()
|
branch = branch.strip()
|
||||||
if not branch.startswith('remotes/origin'):
|
# If we use zuul, there's no need for filtering
|
||||||
|
if not using_zuul and not branch.startswith('remotes/origin'):
|
||||||
continue
|
continue
|
||||||
branches.append(branch)
|
branches.append(branch)
|
||||||
return branches
|
return branches
|
||||||
@ -40,22 +45,31 @@ def git_tags():
|
|||||||
r, tag_list = run_local(['git', 'tag', '-n'])
|
r, tag_list = run_local(['git', 'tag', '-n'])
|
||||||
return [x for x in tag_list.split('\n') if x]
|
return [x for x in tag_list.split('\n') if x]
|
||||||
|
|
||||||
|
|
||||||
current = ''
|
current = ''
|
||||||
previous = ''
|
previous = ''
|
||||||
|
|
||||||
|
# Running under Zuul v3, we do not have remotes/origin.
|
||||||
|
# Running locally, it exists. Let's check ZUUL_PROJECT for running under
|
||||||
|
# Zuul.
|
||||||
|
|
||||||
|
if os.getenv("ZUUL_PROJECT"):
|
||||||
|
remote = ""
|
||||||
|
using_zuul = True
|
||||||
|
|
||||||
for branch in git_branches():
|
for branch in git_branches():
|
||||||
if branch.startswith('remotes/origin/master'):
|
if branch.startswith( remote + 'master'):
|
||||||
continue
|
continue
|
||||||
if branch.startswith('remotes/origin/template'):
|
if branch.startswith( remote + 'template'):
|
||||||
continue
|
continue
|
||||||
if branch.startswith('remotes/origin/HEAD'):
|
if branch.startswith( remote + 'HEAD'):
|
||||||
continue
|
continue
|
||||||
if '->' in branch:
|
if '->' in branch:
|
||||||
continue
|
continue
|
||||||
r,o = run_local(['git', 'show', branch+':README.rst'])
|
r,o = run_local(['git', 'show', branch+':README.rst'])
|
||||||
if not r:
|
if not r:
|
||||||
title = o.split('\n')[0]
|
title = o.split('\n')[0]
|
||||||
name = branch[len('remotes/origin/'):]
|
name = branch[len(remote):]
|
||||||
print "Adding branch %s: %s" % (name, title)
|
print "Adding branch %s: %s" % (name, title)
|
||||||
current += '<a href="%s/">%s</a><br/>\n' % (name, title)
|
current += '<a href="%s/">%s</a><br/>\n' % (name, title)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user