Skip to content

Commit

Permalink
fix: show triggering commit in provider PR titles (#210)
Browse files Browse the repository at this point in the history
This is relatively minor, but it's been bothering me for a while that
our individual providers often end up with changelogs like:

> • deps: Updated
([#549](cdktf/cdktf-provider-snowflake#549))
([df79e2e](cdktf/cdktf-provider-snowflake@df79e2e))
• deps: Updated
([#556](cdktf/cdktf-provider-snowflake#556))
([ab6c52d](cdktf/cdktf-provider-snowflake@ab6c52d))
• deps: Updated
([#558](cdktf/cdktf-provider-snowflake#558))
([28913f7](cdktf/cdktf-provider-snowflake@28913f7))
• deps: Updated
([#559](cdktf/cdktf-provider-snowflake#559))
([7f858c3](cdktf/cdktf-provider-snowflake@7f858c3))
• deps: Updated
([#560](cdktf/cdktf-provider-snowflake#560))
([899a086](cdktf/cdktf-provider-snowflake@899a086))
• deps: Updated
([#577](cdktf/cdktf-provider-snowflake#577))
([f9654e6](cdktf/cdktf-provider-snowflake@f9654e6))

Like, updated _what_? These messages aren't very useful.

These PR titles are generated when we push to main in this repo and the
changes don't result in CDKTF, JSII, the underlying provider, Node, or
Constructs being updated. I recognize that makes it difficult to
articulate what the actual update was. (Most often it's just projen.) I
figure at the very least as a fallback we can link back to the commit to
main in this repo to show what triggered the update in the first place.

With this change, the changelogs will now look like:

> • deps: Updated by 658ad9d
([#560](cdktf/cdktf-provider-snowflake#560))
([899a086](cdktf/cdktf-provider-snowflake@899a086))
• deps: Updated by a8236d4
([#577](cdktf/cdktf-provider-snowflake#577))
([f9654e6](cdktf/cdktf-provider-snowflake@f9654e6))
  • Loading branch information
xiehan authored Jul 27, 2023
1 parent a8236d4 commit 45a811b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion .github/lib/collect-changes.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,29 @@ module.exports = async ({ core, exec }) => {
);
}

if (commitMessageParts.length === 0) {
const repo = 'cdktf/cdktf-repository-manager'; // we could make this dynamic
let commitHash;
try {
commitHash = (
await exec.getExecOutput("git", ["rev-parse", "--short", "HEAD"], {
cwd: path.join(process.env.GITHUB_WORKSPACE, "main"),
})
).stdout;
} catch (e) {
console.log(e);
}
if (commitHash) {
commitMessageParts.push(`by ${repo}@${commitHash}`);
}
}

if (hasBreakingChanges) {
core.setOutput("has_breaking_changes", true);
}

core.setOutput(
"commit_message",
`${prefix} ${commitMessageParts.join(", ")}`
`${prefix} ${commitMessageParts.join(", ")}`.trim()
);
};

0 comments on commit 45a811b

Please sign in to comment.