extend dump plugin to support resolving revisions
This patch adds a flag --resolve-refs to the dump plugin. Once enabled, all relative refspecs (e.g. branch or tag names) are resolved and replaced by their exact revision (before patches are applied). When re-running kas on the flattened and expanded config file, the build is executed against exactly the versions of the dependencies that where used when dumping the configuration. This helps to keep track of build versions for future use (e.g. reproducible builds) or for version-tracking tools like renovate. Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
parent
23dcf955a2
commit
ffabaa19f3
@ -64,7 +64,10 @@ class Dump(Checkout):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
name = 'dump'
|
name = 'dump'
|
||||||
helpmsg = 'Expand and dump the final config.'
|
helpmsg = (
|
||||||
|
'Expand and dump the final config to stdout. When resolving refspecs, '
|
||||||
|
'these are resolved before patches are applied.'
|
||||||
|
)
|
||||||
|
|
||||||
class KasYamlDumper(yaml.Dumper):
|
class KasYamlDumper(yaml.Dumper):
|
||||||
"""
|
"""
|
||||||
@ -99,6 +102,9 @@ class Dump(Checkout):
|
|||||||
type=int,
|
type=int,
|
||||||
default=4,
|
default=4,
|
||||||
help='Line indent (# of spaces, default: 4)')
|
help='Line indent (# of spaces, default: 4)')
|
||||||
|
parser.add_argument('--resolve-refs',
|
||||||
|
action='store_true',
|
||||||
|
help='Replace floating refs with exact SHAs')
|
||||||
|
|
||||||
def run(self, args):
|
def run(self, args):
|
||||||
args.skip += [
|
args.skip += [
|
||||||
@ -116,6 +122,12 @@ class Dump(Checkout):
|
|||||||
if 'includes' in config_expanded['header']:
|
if 'includes' in config_expanded['header']:
|
||||||
del config_expanded['header']['includes']
|
del config_expanded['header']['includes']
|
||||||
|
|
||||||
|
if args.resolve_refs:
|
||||||
|
repos = ctx.config.get_repos()
|
||||||
|
for r in repos:
|
||||||
|
if r.refspec:
|
||||||
|
config_expanded['repos'][r.name]['refspec'] = r.revision
|
||||||
|
|
||||||
if args.format == 'json':
|
if args.format == 'json':
|
||||||
json.dump(config_expanded, sys.stdout, indent=args.indent)
|
json.dump(config_expanded, sys.stdout, indent=args.indent)
|
||||||
sys.stdout.write('\n')
|
sys.stdout.write('\n')
|
||||||
|
Loading…
Reference in New Issue
Block a user