Skip to content

Commit

Permalink
fix(backend): don't generate invalid commits for non-bumped packages
Browse files Browse the repository at this point in the history
  • Loading branch information
dr460nf1r3 committed Nov 18, 2024
1 parent 912ae93 commit 35ba23c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions backend/src/interfaces/repo-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export interface RepoUpdateRunParams {
configs: CiConfigs;
pkg: Package;
triggerFrom: TriggerType;
gotBumped?: boolean;
}

export type CiConfigs = { [key: string]: string };
Expand Down
16 changes: 9 additions & 7 deletions backend/src/repo-manager/repo-manager.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,9 +548,10 @@ class RepoManager {
return { repo: repo.name, bumped: [], origin: TriggerType.ARCH };
}
const bumpedPackages: PackageBumpEntry[] = await this.bumpPackages(needsRebuild, repoDir);
const needsPush = needsRebuild.filter((entry) => entry.gotBumped === true);

Logger.log(`Pushing changes to ${repo.name}`, "RepoManager");
await this.pushChanges(repoDir, needsRebuild, repo);
await this.pushChanges(repoDir, needsPush, repo);

Logger.debug("Done checking for rebuild triggers, cleaning up", "RepoManager");
this.cleanUp([repoDir, ...pkgbaseDirs]);
Expand Down Expand Up @@ -844,9 +845,11 @@ class RepoManager {
});
}
}

void this.dbConnections.packages.save(param.pkg);

// Indicate we bumped the package
param.gotBumped = true;

// We need to update the package in the database to reflect the new bump
const bumpEntry: PackageBumpEntry = {
pkg: param.pkg,
Expand Down Expand Up @@ -1212,8 +1215,8 @@ class RepoManager {
commitMessage += `${param.pkg.pkgname}, `;
commitBody += `- ${param.pkg.pkgname}: ${bumpReason}\n`;

if (counter % 2 === 0 || counter === needsRebuild.length - 1) {
commitMessage = commitMessage.slice(0, commitMessage.length - 2)
if ((counter !== 0 && counter % 2 === 0) || counter === needsRebuild.length - 1) {
commitMessage = commitMessage.slice(0, commitMessage.length - 2);
commitMessage += `\n\n${commitBody}`;

await git.commit({
Expand All @@ -1228,7 +1231,7 @@ class RepoManager {
commitMessage = "chore(bump): ";
commitBody = "";
}
counter++
counter++;
} catch (err: unknown) {
Logger.error(err, "RepoManager");
}
Expand Down Expand Up @@ -1404,8 +1407,7 @@ class RepoManager {

// Prevent CI uselessly rewriting config files because of non-alphabetic order
const writeBack: [string, string][] = Object.entries(pkgConfig.configs);
writeBack.sort((a, b) => a[0].localeCompare(b[0]));

writeBack.sort();
for (const [key, value] of writeBack) {
try {
if (key === "pkg" || (key || value) === undefined) continue;
Expand Down

0 comments on commit 35ba23c

Please sign in to comment.