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

If a pull request closes an issue, check that issue's title / tags to categorize the contribution #71

Open
choldgraf opened this issue Jul 25, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@choldgraf
Copy link
Member

Context

We currently check for tags or metadata in titles for the pull request that was merged within a given window:

# Separate out items by their tag types
for kind, kindmeta in tags_metadata.items():
# First find the PRs based on tag
mask = closed_prs["labels"].map(
lambda a: any(ii == jj for ii in kindmeta["tags"] for jj in a)
)
# Now find PRs based on prefix
mask_pre = closed_prs["title"].map(
lambda title: any(f"{ipre}:" in title for ipre in kindmeta["pre"])
)
mask = mask | mask_pre
kindmeta["data"] = closed_prs.loc[mask]
kindmeta["mask"] = mask

However, many projects put more labeling / tagging effort into their issues rather than the pull requests that close them. For example, a PR might have no labels itself, but might close an issue labeled documentation.

Proposal

If a Pull Request doesn't contain any information that can be used to categorize it, but it does have an issue that it closes, then we should try to infer the "category" of the PR by looking at the issue's information.

Note on implementation

We can grab the pointer to a closing issue via the closingIssuesReferences graphql field. We can then use this to return the title and list of labels for that issue. Here's a rough query that does this for a generic pull requests query:

{
  viewer {
    pullRequests(
      first: 100
      states: CLOSED
      orderBy: {field: UPDATED_AT, direction: DESC}
    ) {
      nodes {
        closingIssuesReferences(first: 5) {
          edges {
            node {
              labels(first:10) {
                edges {
                  node {
                    id
                    name
                    url
                  }
                }
              }
              title
              url
            }
          }
        }
      }
    }
  }
}

Tasks and updates

No response

@choldgraf choldgraf added the enhancement New feature or request label Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant