git-for-windows / gfw-helper-github-app

2 stars 6 forks source link

/open pr doesn't link to the issue it closes anymore. #18

Closed rimrul closed 1 year ago

rimrul commented 1 year ago

It used to do that (see https://github.com/git-for-windows/MSYS2-packages/pull/71#issue-1505887299), but does not do so anymore (see https://github.com/git-for-windows/MSYS2-packages/pull/72#issue-1510034720)

dscho commented 1 year ago

But the latter wasn't merged, was it? And please note the the first one had "This closes git-for-windows/git#4191" in its initial comment...

dscho commented 1 year ago

Ah. I think I know the root cause. This code tries to determine whether there is any component-update ticket that could be closed by the opened PR.

Note that it looks for the exact version in the title. Without leading v, except for Git LFS.

I guess it would be better to be lenient and try the version without leading v first, and if there are no hits, dig deeper. Or maybe an "OR" works? A quick test:

So I guess what we want is this:

diff --git a/.github/workflows/open-pr.yml b/.github/workflows/open-pr.yml
index 6bb1b7a..1b6b889 100644
--- a/.github/workflows/open-pr.yml
+++ b/.github/workflows/open-pr.yml
@@ -180,7 +180,7 @@ jobs:
             let body = ''
             try {
               const name = process.env.PACKAGE_TO_UPGRADE
-              const version = `${name.match(/git-lfs/) ? 'v' : ''}${process.env.UPGRADE_TO_VERSION}`
+              const version = process.env.UPGRADE_TO_VERSION

               if (name === 'mintty') body = `See https://github.com/mintty/mintty/releases/tag/${version} for details.`
               else if (name === 'mingw-w64-git-lfs') body = `See https://github.com/git-lfs/git-lfs/releases/tag/${version} for details.`
@@ -188,7 +188,7 @@ jobs:

               const terms = 'type:issue repo:git-for-windows/git state:open author:app/github-actions label:component-update'
               const { data } = await github.rest.search.issuesAndPullRequests({
-                q: `"[New ${name.replace(/^mingw-w64-/, '')} version]" ${version} in:title ${terms}`,
+                q: `"[New ${name.replace(/^mingw-w64-/, '')} version]" (${version} OR v${version}) in:title ${terms}`,
               })
               if (data.total_count) body = `${body ? `${body}\n\n` : ''}This closes ${data.items[0].html_url}`
             } catch (e) {
dscho commented 1 year ago

@rimrul and here is the Pull Request that throws in a commit message with that diff.

dscho commented 1 year ago

This should be fixed via https://github.com/git-for-windows/git-for-windows-automation/pull/9.