ostbuild: Enhance source-diff with --log and --logp options
This commit is contained in:
parent
6d59b4077c
commit
9bd36f9bff
|
|
@ -36,6 +36,39 @@ class OstbuildSourceDiff(builtins.Builtin):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
builtins.Builtin.__init__(self)
|
builtins.Builtin.__init__(self)
|
||||||
|
|
||||||
|
def _diff(self, name, mirrordir, from_revision, to_revision):
|
||||||
|
env = dict(os.environ)
|
||||||
|
env['LANG'] = 'C'
|
||||||
|
|
||||||
|
spacename = ' ' + name
|
||||||
|
|
||||||
|
proc = subprocess.Popen(['git', 'diff', from_revision, to_revision],
|
||||||
|
env=env, cwd=mirrordir, stdout=subprocess.PIPE)
|
||||||
|
for line in proc.stdout:
|
||||||
|
if (line.startswith('diff --git ')
|
||||||
|
or line.startswith('--- a/')
|
||||||
|
or line.startswith('+++ b/')
|
||||||
|
or line.startswith('Binary files /dev/null and b/')):
|
||||||
|
line = diff_replace_re.sub(spacename, line)
|
||||||
|
sys.stdout.write(line)
|
||||||
|
else:
|
||||||
|
sys.stdout.write(line)
|
||||||
|
proc.wait()
|
||||||
|
|
||||||
|
def _log(self, opts, name, mirrordir, from_revision, to_revision):
|
||||||
|
env = dict(os.environ)
|
||||||
|
env['LANG'] = 'C'
|
||||||
|
|
||||||
|
spacename = ' ' + name
|
||||||
|
|
||||||
|
args = ['git', 'log']
|
||||||
|
args.extend(opts)
|
||||||
|
args.append(from_revision + '...' + to_revision)
|
||||||
|
proc = subprocess.Popen(args, env=env, cwd=mirrordir, stdout=subprocess.PIPE)
|
||||||
|
for line in proc.stdout:
|
||||||
|
sys.stdout.write(line)
|
||||||
|
proc.wait()
|
||||||
|
|
||||||
def _snapshot_from_rev(self, rev):
|
def _snapshot_from_rev(self, rev):
|
||||||
self.init_repo()
|
self.init_repo()
|
||||||
text = run_sync_get_output(['ostree', '--repo=' + self.repo,
|
text = run_sync_get_output(['ostree', '--repo=' + self.repo,
|
||||||
|
|
@ -45,6 +78,8 @@ class OstbuildSourceDiff(builtins.Builtin):
|
||||||
|
|
||||||
def execute(self, argv):
|
def execute(self, argv):
|
||||||
parser = argparse.ArgumentParser(description=self.short_description)
|
parser = argparse.ArgumentParser(description=self.short_description)
|
||||||
|
parser.add_argument('--log', action='store_true')
|
||||||
|
parser.add_argument('--logp', action='store_true')
|
||||||
parser.add_argument('--rev-from')
|
parser.add_argument('--rev-from')
|
||||||
parser.add_argument('--rev-to')
|
parser.add_argument('--rev-to')
|
||||||
parser.add_argument('--snapshot-from')
|
parser.add_argument('--snapshot-from')
|
||||||
|
|
@ -99,22 +134,11 @@ class OstbuildSourceDiff(builtins.Builtin):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if from_revision != to_revision:
|
if from_revision != to_revision:
|
||||||
env = dict(os.environ)
|
if args.log:
|
||||||
env['LANG'] = 'C'
|
self._log([], name, mirrordir, from_revision, to_revision)
|
||||||
|
elif args.logp:
|
||||||
spacename = ' ' + name
|
self._log(['-p'], name, mirrordir, from_revision, to_revision)
|
||||||
|
else:
|
||||||
proc = subprocess.Popen(['git', 'diff', from_revision, to_revision],
|
self._diff(name, mirrordir, from_revision, to_revision)
|
||||||
env=env, cwd=mirrordir, stdout=subprocess.PIPE)
|
|
||||||
for line in proc.stdout:
|
|
||||||
if (line.startswith('diff --git ')
|
|
||||||
or line.startswith('--- a/')
|
|
||||||
or line.startswith('+++ b/')
|
|
||||||
or line.startswith('Binary files /dev/null and b/')):
|
|
||||||
line = diff_replace_re.sub(spacename, line)
|
|
||||||
sys.stdout.write(line)
|
|
||||||
else:
|
|
||||||
sys.stdout.write(line)
|
|
||||||
proc.wait()
|
|
||||||
|
|
||||||
builtins.register(OstbuildSourceDiff)
|
builtins.register(OstbuildSourceDiff)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue