Skip to content

Commit

Permalink
Merge pull request #2403 from cms-sw/pr-squash-2
Browse files Browse the repository at this point in the history
Only reset signatures for modified files on dirty squash
  • Loading branch information
smuzaffar authored Dec 12, 2024
2 parents 0972821 + 8ff4700 commit 0405411
Show file tree
Hide file tree
Showing 4 changed files with 240 additions and 4 deletions.
12 changes: 8 additions & 4 deletions process_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1683,6 +1683,7 @@ def process_pr(repo_config, gh, repo, issue, dryRun, cmsbuild_user=None, force=F
).difference(all_commit_shas)
last_seen_commit_time = None
new_commits = set()
files_changed_in_squash = []
if missing_commits:
print(
"Possible squash detected: the following commits were cached, but missing from PR"
Expand Down Expand Up @@ -1718,13 +1719,15 @@ def process_pr(repo_config, gh, repo, issue, dryRun, cmsbuild_user=None, force=F
(file.filename, file.sha) for file in changes_before_squash.files
}
diff_after_squash = {(file.filename, file.sha) for file in changes_after_squash.files}
diff_in_squash = diff_before_squash ^ diff_after_squash

if diff_before_squash ^ diff_after_squash:
if diff_in_squash:
print("PR diff changed, will not preserve signatures")
files_changed_in_squash = list(set(x[0] for x in diff_in_squash))
else:
print("PR diff not changed, preserving signatures and commit statuses")
last_seen_commit_time = bot_cache["commits"][last_seen_commit_sha]["time"]
new_commits = all_commit_shas.difference(k for k in bot_cache["commits"])
new_commits = all_commit_shas.difference(k for k in bot_cache["commits"])

# Mark removed commits in cache as squashed
for commit_sha in missing_commits:
Expand All @@ -1749,8 +1752,9 @@ def process_pr(repo_config, gh, repo, issue, dryRun, cmsbuild_user=None, force=F
bot_cache["commits"][commit.sha]["files"] = []

if commit.sha in new_commits:
bot_cache["commits"][commit.sha]["files"] = []
bot_cache["commits"][commit.sha]["time"] = last_seen_commit_time
bot_cache["commits"][commit.sha]["files"] = files_changed_in_squash
if last_seen_commit_time: # clean squash
bot_cache["commits"][commit.sha]["time"] = last_seen_commit_time

cache_entry = bot_cache["commits"][commit.sha]
events[datetime.fromtimestamp(cache_entry["time"])].append(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
[
{
"type": "load-bot-cache",
"data": {
"commits": {
"1495b64c35fc2c4ef98688d2958fc39490b8d2e1": {
"files": [
"L1Trigger/CSCTrackFinder/BuildFile.xml"
],
"squashed": true,
"time": 1734005540
},
"4ae404d88e0c25c511b3cbaa031e116669676fec": {
"files": [
"FWCore/Integration/BuildFile.xml"
],
"squashed": true,
"time": 1734005038
},
"c6cd57066c758445d041e3a3708c71f166593b9a": {
"time": 1734005679,
"squashed": false,
"files": [
"L1Trigger/CSCTrackFinder/BuildFile.xml"
]
}
},
"emoji": {
"2538875283": "+1",
"2538876197": "+1"
},
"last_seen_sha": "c6cd57066c758445d041e3a3708c71f166593b9a",
"signatures": {
"2538875283": "1495b64c35fc2c4ef98688d2958fc39490b8d2e1",
"2538876197": "1495b64c35fc2c4ef98688d2958fc39490b8d2e1"
}
}
},
{
"type": "emoji",
"data": [
2538875283,
"+1",
true
]
},
{
"type": "emoji",
"data": [
2538876197,
"+1",
true
]
},
{
"type": "add-label",
"data": [
"code-checks-pending",
"l1-pending",
"pending-signatures"
]
},
{
"type": "remove-label",
"data": [
"code-checks-approved",
"fully-signed",
"l1-approved"
]
},
{
"type": "create-property-file",
"data": {
"filename": "trigger-code-checks-iarspider-cmssw-cmssw-23.properties",
"data": {
"PULL_REQUEST": "23",
"CONTEXT_PREFIX": "cms/23",
"CMSSW_TOOL_CONF": "",
"APPLY_PATCH": "false"
}
}
},
{
"type": "status",
"data": {
"commit": "c6cd57066c758445d041e3a3708c71f166593b9a",
"state": "pending",
"target_url": null,
"description": "code-checks requested",
"context": "cms/23/code-checks"
}
},
{
"type": "edit-comment",
"data": "cms-bot internal usage<!-- bot cache: {\"commits\":{\"1495b64c35fc2c4ef98688d2958fc39490b8d2e1\":{\"files\":[\"L1Trigger/CSCTrackFinder/BuildFile.xml\"],\"squashed\":true,\"time\":1734005540},\"4ae404d88e0c25c511b3cbaa031e116669676fec\":{\"files\":[\"FWCore/Integration/BuildFile.xml\"],\"squashed\":true,\"time\":1734005038},\"c6cd57066c758445d041e3a3708c71f166593b9a\":{\"files\":[\"L1Trigger/CSCTrackFinder/BuildFile.xml\"],\"squashed\":false,\"time\":1734005679}},\"emoji\":{\"2538875283\":\"+1\",\"2538876197\":\"+1\"},\"last_seen_sha\":\"c6cd57066c758445d041e3a3708c71f166593b9a\",\"signatures\":{\"2538875283\":\"1495b64c35fc2c4ef98688d2958fc39490b8d2e1\",\"2538876197\":\"1495b64c35fc2c4ef98688d2958fc39490b8d2e1\"}} -->"
}
]
Loading

0 comments on commit 0405411

Please sign in to comment.