Skip to content

Commit

Permalink
config-bot: support branch-level skip files
Browse files Browse the repository at this point in the history
With the new experimental stream, we want to have more freedom in what
files go in there without having to also pollute `testing-devel`.

Add support for a `.coreos.skip-files` file which will tell config-bot
to not clobber a specific set of files on that ref. This augments the
global-level `skip-files` list.

Related: coreos/fedora-coreos-tracker#1446
  • Loading branch information
jlebon committed May 3, 2023
1 parent cad1c93 commit 903e815
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config-bot/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ target-refs = [
'rawhide',
'experimental',
]
# Files to not clobber in target refs.
# Ref-specific skip files can be specified in `.coreos.skip-files`.
skip-files = [
'manifest.yaml',
'manifest-lock.*',
Expand Down
18 changes: 17 additions & 1 deletion config-bot/main
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ logging.basicConfig(


DEFAULT_CONFIG_FILE_PATH = "/etc/config-bot.toml"
REF_LEVEL_SKIP_FILES = ".coreos.skip-files"

git = None

Expand Down Expand Up @@ -270,14 +271,29 @@ async def propagate_files(cfg):
for target_ref in target_refs:
git.checkout(target_ref)

ref_skip_files = []
try:
ref_skip_files_fn = git.path(REF_LEVEL_SKIP_FILES)
with open(ref_skip_files_fn, encoding='utf-8') as f:
ref_skip_files = f.read().splitlines()
# filter out blank lines and comments
ref_skip_files = [fn for fn in ref_skip_files
if len(fn) and not fn.startswith("#")]
# the skip-file itself is always skipped
ref_skip_files += [REF_LEVEL_SKIP_FILES]
except FileNotFoundError:
pass

ref_skip_files += skip_files

# We want the same semantics as `rsync --delete`, i.e. delete
# files in the target ref no longer in the source ref. We'll do
# this by first deleting all the files, then importing the new
# files.
all_files = git.cmd_output('ls-tree', target_ref,
'--name-only').splitlines()
files_to_delete = [f for f in all_files
if not matches_patterns(f, skip_files)]
if not matches_patterns(f, ref_skip_files)]

git.cmd('rm', '-r', '--', *files_to_delete)
git.cmd('checkout', source_ref, '--', *files_to_import)
Expand Down

0 comments on commit 903e815

Please sign in to comment.