Skip to content

Commit

Permalink
Merge pull request #171 from jlebon/pr/configbot-experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
jlebon committed May 18, 2023
2 parents eef495c + 903e815 commit e820eb9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions config-bot/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ target-refs = [
'next-devel',
'branched',
'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 e820eb9

Please sign in to comment.