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

[reg-notify-github-plugin] Support PR created by forked repository #159

Open
kogai opened this issue Oct 12, 2019 · 5 comments
Open

[reg-notify-github-plugin] Support PR created by forked repository #159

kogai opened this issue Oct 12, 2019 · 5 comments

Comments

@kogai
Copy link

kogai commented Oct 12, 2019

Is your feature request related to a problem? Please describe.

It would be happy when reg-notify-github-plugin supports to comment PR which created by a forked repository

Describe the solution you'd like

I haven't any idea to solve it but https://github.com/reg-viz/gh-app/tree/master/packages/backend seems related to

Describe alternatives you've considered

Additional context

@Quramy
Copy link
Member

Quramy commented Oct 16, 2019

Hi @kogai and sorry for my late reply.

Please tell me your usecase. Which is the followings or other?

  • (A): You want gh-plugin's comment to the original repository by your PR
  • (B): You want gh-plugin's comment to your forked repository by your PR

If you want (A), it may be our plugin issue, the real implementation is in reg-gh-app as you said.
If you want (B), you should install https://github.com/apps/reg-suit to not orijinal repo but your forked repo because of GitHub Apps permission spec.

@kogai
Copy link
Author

kogai commented Oct 17, 2019

(A): You want gh-plugin's comment to the original repository by your PR

A is the case I've faced 🙏
It would be glad if reg-notify-github-plugin support such cases.

By the way, if all reg-suit packages going to supports such cases, perhaps reg-keygen-git-hash-plugin should be supports too which to compare between forked-repo:my-branch and original-repo:master 🤔

@Quramy
Copy link
Member

Quramy commented Oct 17, 2019

A is the case I've faced

Thanks, I got it and I'll investigate it.

And we're attempting problems about 'forked repo', however they're hard.

@dora1998
Copy link
Contributor

I also want this feature (i.e. usecase (A)) 👍

If the plugin is able to get PR number from config (like #195), we can use the plugin in this usecase.
For example,

  • GitHub Acions

We can get PR number from github.event.pull_request.number when an Action runs.

  • CircleCI

We can get PR number from CIRCLE_PR_NUMBER env when an CI runs.

@Quramy
If you agree with this approach, I want to create PR. What do you think about this?

@Quramy
Copy link
Member

Quramy commented Sep 18, 2020

For now, reg suit GitHub app uses the following query to detect PR to comment ( This GitHub app accepts owner, repo name, branch name of HEAD ):

query UpdatePrCommentContext($branchName: String!, $owner: String!, $repository: String!) {
  repository(owner: $owner, name: $repository) {
    nameWithOwner
    ref(qualifiedName: $branchName) {
      associatedPullRequests(last: 5, states: OPEN) {
        totalCount,
        nodes {
          id, number
          comments(first: 50) {
            totalCount
            nodes {
              databaseId, createdAt, viewerDidAuthor
            }
          }
        }
      }
    }
  }
}

https://github.com/reg-viz/gh-app/blob/master/packages/backend/src/gql/update-pr-comment-context.graphql

But this query can't look for forked repository because ref(qualifiedName: $branchName) does not make sense .

And I think we'll fix this issue by query such as:

query {
  repository(owner: "reg-viz", name: "reg-suit") {
    id
    pullRequests(first: 2, states: OPEN, orderBy: { field: UPDATED_AT, direction: DESC }, headRefName: "patch-1") {
      nodes {
        title
        headRefName
        headRepositoryOwner {
          login
        }
        id
        number
        comments(first: 50) {
          totalCount
          nodes {
            databaseId, createdAt, viewerDidAuthor
          }
        }
      }
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants