Commit b0f0d1a7 authored by Klaus Weidner's avatar Klaus Weidner Committed by Commit Bot

Ignore recent local commits when computing the LASTCHANGE position.

For unclear reasons, the build/util/LASTCHANGE file frequently contained
the hash of a local-only commit from a working branch, and the result
was a 404 error when trying to inspect a page in devtools.

To avoid this, add a --filter regex that is passed to "git log --grep",
defaulting to '^Change-Id:'. This header is present for the main
source tree and third_party/skia/ official commits.

BUG=760304

Change-Id: I9464ba37a1197872a7ffd31b8c2f1a2a85856276
Reviewed-on: https://chromium-review.googlesource.com/949312Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Reviewed-by: default avatarPavel Feldman <pfeldman@chromium.org>
Commit-Queue: Klaus Weidner <klausw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541137}
parent f81152dc
......@@ -46,7 +46,7 @@ def RunGitCommand(directory, command):
return None
def FetchGitRevision(directory):
def FetchGitRevision(directory, filter):
"""
Fetch the Git hash (and Cr-Commit-Position if any) for a given directory.
......@@ -57,6 +57,8 @@ def FetchGitRevision(directory):
"""
hsh = ''
git_args = ['log', '-1', '--format=%H']
if filter is not None:
git_args.append('--grep=' + filter)
proc = RunGitCommand(directory, git_args)
if proc:
output = proc.communicate()[0].strip()
......@@ -76,12 +78,12 @@ def FetchGitRevision(directory):
return VersionInfo(hsh, '%s-%s' % (hsh, pos))
def FetchVersionInfo(directory=None):
def FetchVersionInfo(directory=None, filter=None):
"""
Returns the last change (as a VersionInfo object)
from some appropriate revision control system.
"""
version_info = FetchGitRevision(directory)
version_info = FetchGitRevision(directory, filter)
if not version_info:
version_info = VersionInfo('0', '0')
return version_info
......@@ -165,10 +167,16 @@ def main(argv=None):
"file-output-related options.")
parser.add_option("-s", "--source-dir", metavar="DIR",
help="Use repository in the given directory.")
parser.add_option("", "--filter", metavar="REGEX",
help="Only use log entries where the commit message " +
"matches the supplied filter regex. Defaults to " +
"'^Change-Id:' to suppress local commits.",
default='^Change-Id:')
opts, args = parser.parse_args(argv[1:])
out_file = opts.output
header = opts.header
filter=opts.filter
while len(args) and out_file is None:
if out_file is None:
......@@ -183,7 +191,7 @@ def main(argv=None):
else:
src_dir = os.path.dirname(os.path.abspath(__file__))
version_info = FetchVersionInfo(directory=src_dir)
version_info = FetchVersionInfo(directory=src_dir, filter=filter)
revision_string = version_info.revision
if opts.revision_id_only:
revision_string = version_info.revision_id
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment