Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config-bot: add experimental branch and support branch-level skip files #171

Merged
merged 2 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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