feat: add git commit to about:buildconfig page
(cherry picked from commit 0e34696456751fd261385aa76f012e8210c4a150)
This commit is contained in:
@@ -38,6 +38,19 @@ def get_program_output(*command):
|
||||
except Exception:
|
||||
return ""
|
||||
|
||||
def get_git_info(workdir):
|
||||
repo = get_program_output('git', '-C', workdir, 'remote', 'get-url', 'origin')
|
||||
if repo:
|
||||
repo = repo.strip()
|
||||
if repo.startswith("ssh://"):
|
||||
repo = "https://" + repo[6:]
|
||||
repo = repo.rstrip("/")
|
||||
if repo.endswith('.git'):
|
||||
repo = repo[:-4]
|
||||
|
||||
changeset = get_git_changeset(workdir)
|
||||
|
||||
return repo, changeset
|
||||
|
||||
def get_hg_info(workdir):
|
||||
repo = get_program_output("hg", "-R", workdir, "path", "default")
|
||||
@@ -51,6 +64,8 @@ def get_hg_info(workdir):
|
||||
|
||||
return repo, changeset
|
||||
|
||||
def get_git_changeset(path):
|
||||
return get_program_output('git', '-C', path, 'rev-parse', 'HEAD')
|
||||
|
||||
def get_hg_changeset(path):
|
||||
return get_program_output("hg", "-R", path, "parent", "--template={node}")
|
||||
@@ -91,10 +106,12 @@ def source_repo_header(output):
|
||||
sourcestamp_path = os.path.join(buildconfig.topsrcdir, SOURCESTAMP_FILENAME)
|
||||
if os.path.exists(os.path.join(buildconfig.topsrcdir, ".hg")):
|
||||
repo, changeset = get_hg_info(buildconfig.topsrcdir)
|
||||
elif os.path.exists(os.path.join(buildconfig.topsrcdir, ".git")):
|
||||
repo, changeset = get_git_info(buildconfig.topsrcdir)
|
||||
elif os.path.exists(sourcestamp_path):
|
||||
repo, changeset = get_info_from_sourcestamp(sourcestamp_path)
|
||||
elif not changeset:
|
||||
changeset = get_hg_changeset(buildconfig.topsrcdir)
|
||||
changeset = get_git_changeset(buildconfig.topsrcdir)
|
||||
if not changeset:
|
||||
raise Exception(
|
||||
"could not resolve changeset; " "try setting MOZ_SOURCE_CHANGESET"
|
||||
@@ -104,7 +121,7 @@ def source_repo_header(output):
|
||||
output.write("#define MOZ_SOURCE_STAMP %s\n" % changeset)
|
||||
|
||||
if repo and buildconfig.substs.get("MOZ_INCLUDE_SOURCE_INFO"):
|
||||
source = "%s/rev/%s" % (repo, changeset)
|
||||
source = "%s/commit/%s" % (repo, changeset)
|
||||
output.write("#define MOZ_SOURCE_REPO %s\n" % repo)
|
||||
output.write("#define MOZ_SOURCE_URL %s\n" % source)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user