Skip to content

Commit 3855a91

Browse files
committed
contest: track if branch has changes since the previous one
Add a tiny bit of metadata to tell us the branch is identical. This can be technically computed offline but the branches are garbage collected quickly so for a historical view metadata is better. Signed-off-by: Jakub Kicinski <[email protected]>
1 parent b273092 commit 3855a91

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pw_brancher.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,18 @@ def generate_deltas(config, tree, name):
204204
subprocess.run([cidiff, name], cwd=tree.path, stdout=fp, check=True)
205205

206206

207+
def get_change_from_last(tree, branch_list) -> bool:
208+
branch_list = list(sorted(branch_list))
209+
if len(branch_list) < 2:
210+
return True
211+
212+
try:
213+
tree.git(['diff', '--quiet', branch_list[-1], branch_list[-2]])
214+
return False
215+
except:
216+
return True
217+
218+
207219
def create_new(pw, config, state, tree, tgt_remote) -> None:
208220
now = datetime.datetime.now(datetime.UTC)
209221
pfx = config.get("target", "branch_pfx")
@@ -241,6 +253,8 @@ def create_new(pw, config, state, tree, tgt_remote) -> None:
241253
extras = apply_local_patches(config, tree)
242254
state["info"][branch_name]["extras"] = extras
243255

256+
state["info"][branch_name]["new-changes"] = get_change_from_last(tree, state["info"].keys())
257+
244258
state["branches"][branch_name] = now.isoformat()
245259

246260
db_insert(config, state, branch_name)

0 commit comments

Comments
 (0)