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

[draft] Mark all new commits as having no files on clean squash #2163

Merged
Merged
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
11 changes: 5 additions & 6 deletions process_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ def process_pr(repo_config, gh, repo, issue, dryRun, cmsbuild_user=None, force=F
pre_checks_url = {}
events = defaultdict(list)
all_commits = []
all_commit_shas = []
all_commit_shas = set()
ok_too_many_commits = False
warned_too_many_commits = False

Expand Down Expand Up @@ -997,7 +997,7 @@ def process_pr(repo_config, gh, repo, issue, dryRun, cmsbuild_user=None, force=F
print("Watchers " + ", ".join(watchers))

all_commits = get_pr_commits_reversed(pr)
all_commit_shas = [commit.sha for commit in all_commits]
all_commit_shas = {commit.sha for commit in all_commits}

if all_commits:
last_commit_obj = all_commits[0]
Expand Down Expand Up @@ -1518,6 +1518,7 @@ def process_pr(repo_config, gh, repo, issue, dryRun, cmsbuild_user=None, force=F
k for k in bot_cache["commits"] if not bot_cache["commits"][k].get("squashed", False)
).difference(all_commit_shas)
last_seen_commit_time = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove this?

new_commits = set()
if missing_commits:
print(
"Possible squash detected: the following commits were cached, but missing from PR"
Expand Down Expand Up @@ -1550,6 +1551,7 @@ def process_pr(repo_config, gh, repo, issue, dryRun, cmsbuild_user=None, force=F
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"])

# TODO: Remove this block
# Restore commit/pre-checks statuses
Expand Down Expand Up @@ -1607,10 +1609,7 @@ def process_pr(repo_config, gh, repo, issue, dryRun, cmsbuild_user=None, force=F
elif len(commit.parents) > 1:
bot_cache["commits"][commit.sha]["files"] = []

if (
last_seen_commit_time
and commit.commit.committer.date.timestamp() > last_seen_commit_time
):
if commit.sha in new_commits:
bot_cache["commits"][commit.sha]["files"] = []
bot_cache["commits"][commit.sha]["time"] = last_seen_commit_time

Expand Down
Loading