Unverified Commit b92d15f9 authored by Andrej Shadura's avatar Andrej Shadura
Browse files

Verify the files have actually changed before committing them

This prevents the creation of empty no-change commits.

Signed-off-by: Andrej Shadura's avatarAndrej Shadura <andrew.shadura@collabora.co.uk>
parent 7039d042
......@@ -217,4 +217,17 @@ def do_dput(self, subcmd, opts, proj_name, dsc_or_changes_file):
msg = changes.get('changes', msg)
added = set(package.to_be_added)
# We don’t want to create commits with no actual changes.
# We only proceed with the commit in these cases:
# 1. If any new file is added (added are more files than superseded)
# 2. Any of the files is of a different size than recorded
# 3. Any of the files has a different MD5 hash than recorded
files_changed = (any(added - superseded) or
any(os.path.getsize(f) != remote_file_list[f].size for f in superseded & added) or
any(osc.core.dgst(f) != remote_file_list[f].md5 for f in superseded & added))
if files_changed:
print("No changes, not submitting anything")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment