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

Linking to an issue creates closes token in readme which closes the issue when merged #2362

Open
steveoh opened this issue Aug 27, 2024 · 0 comments
Assignees
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue.

Comments

@steveoh
Copy link

steveoh commented Aug 27, 2024

What you're trying to do

I am trying to understand where in our pipeline this functionality is handled and if it is expected or not.

We link to issues in github commits. We use the convention of refs #issue when the commit references an issue but does not close it. When we do want a linked commit to close we use fixes #issue but from the github docs any of the following will perform that action.

  • close
  • closes
  • closed
  • fix
  • fixes
  • fixed
  • resolve
  • resolves
  • resolved

This commit used the pattern Ref 182 and the resulting release pull request added a , closes #182 which is not accurate.

image

It appears that the code below possibly ignores the value and groups closes and refs together?

// Populates references array from footers:
// references: [{
// action: 'Closes',
// owner: null,
// repository: null,
// issue: '1', raw: '#1',
// prefix: '#'
// }]
visit(ast, ['footer'], (node: parser.Footer) => {
const reference: parser.Reference = {
prefix: '#',
action: '',
issue: '',
};
let hasRefSepartor = false;
visit(
node,
['type', 'separator', 'text'],
(node: parser.Type | parser.Separator | parser.Text) => {
switch (node.type) {
case 'type':
// refs, closes, etc:
// TODO(@bcoe): conventional-changelog does not currently use
// "reference.action" in its templates:
reference.action = node.value;
break;
case 'separator':
// Footer of the form "Refs #99":
if (node.value.includes('#')) hasRefSepartor = true;
break;
case 'text':
// Footer of the form "Refs: #99"
if (node.value.charAt(0) === '#') {
hasRefSepartor = true;
reference.issue = node.value.substring(1);
// TODO(@bcoe): what about references like "Refs: #99, #102"?
} else {
reference.issue = node.value;
}
break;
}
}
);
// TODO(@bcoe): how should references like "Refs: v8:8940" work.
if (hasRefSepartor && reference.issue.match(NUMBER_REGEX)) {
headerCommit.references.push(reference);
}
});

This code suggests that closes is presumptuous and it should be refs which aligns with my expectation but is not a part of the node strategy.

// "closes" is a little presumptuous, let's just indicate that the
// PR references these other commits:
protected async buildReleaseNotes(
conventionalCommits: ConventionalCommit[],
newVersion: Version,
newVersionTag: TagName,
latestRelease?: Release,
commits?: Commit[]
): Promise<string> {
const releaseNotes = await super.buildReleaseNotes(
conventionalCommits,
newVersion,
newVersionTag,
latestRelease,
commits
);
return releaseNotes.replace(/, closes /g, ', refs ');
}

Is this expected behavior and we need to retrain how we link to issues without closing them or can this be fixed in the strategy or release note writer?

@steveoh steveoh added priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue. labels Aug 27, 2024
@steveoh steveoh changed the title Linking to an issue closes issue Linking to an issue creates closes token in readme which closes the issue when merged Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

2 participants