[FIX] runbot_merge: rebase logging

The logging line was copied over from the github-api version, but it
was not correctly fixed up to match, leading to a lot of spam on
stderr when debug is enabled (aka spams journalctl on the production
server).

Splat the logging call out of `rebase` and into the various callers,
so they have access to the pr object to log it.
This commit is contained in:
Xavier Morel 2024-01-16 09:45:49 +01:00
parent 1cb31cf2c2
commit 45f0c8cc81
3 changed files with 9 additions and 2 deletions

View File

@ -125,8 +125,6 @@ class Repo:
repo = self.stdout().with_config(text=True, check=False)
logger = _logger.getChild('rebase')
logger.debug("rebasing %s on %s (reset=%s, commits=%s)",
self._repo, dest, len(commits))
if not commits:
raise MergeError("PR has no commits")

View File

@ -242,6 +242,8 @@ class FreezeWizard(models.Model):
except Exception as e:
raise UserError(f"Unable to fetch commits of release PR {rel.pr_id.display_name}.") from e
_logger.debug("rebasing %s on %s (commits=%s)",
rel.pr_id.display_name, prev, len(commits))
rel_heads[repo_id] = repos[repo_id].rebase(prev, commits)[0]
# prep bump
@ -260,6 +262,8 @@ class FreezeWizard(models.Model):
except Exception as e:
raise UserError(f"Unable to fetch commits of bump PR {bump.pr_id.display_name}.") from e
_logger.debug("rebasing %s on %s (commits=%s)",
bump.pr_id.display_name, prev, len(commits))
bump_heads[repo_id] = repos[repo_id].rebase(prev, commits)[0]
deployed = {}

View File

@ -490,12 +490,17 @@ def stage_rebase_ff(pr: PullRequests, info: StagingSlice, commits: List[github.P
msg = pr._build_merge_message(commits[-1]['commit']['message'], related_prs=related_prs)
commits[-1]['commit']['message'] = str(msg)
add_self_references(pr, commits[:-1])
_logger.debug("rebasing %s on %s (commits=%s)",
pr.display_name, info.head, len(commits))
head, mapping = info.repo.rebase(info.head, commits=commits)
pr.commits_map = json.dumps({**mapping, '': head})
return head
def stage_rebase_merge(pr: PullRequests, info: StagingSlice, commits: List[github.PrCommit], related_prs: PullRequests) -> str :
add_self_references(pr, commits)
_logger.debug("rebasing %s on %s (commits=%s)",
pr.display_name, info.head, len(commits))
h, mapping = info.repo.rebase(info.head, commits=commits)
msg = pr._build_merge_message(pr, related_prs=related_prs)