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

feature: check for existing updates with same src url #316

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ryantm
Copy link
Collaborator

@ryantm ryantm commented Aug 29, 2022

fixes #315

@rhendric interested in reviewing this?

@rhendric
Copy link
Member

rhendric commented Aug 29, 2022

Wouldn't this solution mean that a PR for firefox would prevent PRs for firefox-beta-bin or any other Firefox variation that uses the same wrapper?

Maybe a better check would be to do something like hashing the diffs created?

@ryantm ryantm changed the title feature: check for existing updates with same meta position feature: check for existing updates with same src url Aug 30, 2022
@ryantm
Copy link
Collaborator Author

ryantm commented Aug 30, 2022

@rhendric Good point, how about how it is now where it checks for a duplicate src URL?

@rhendric
Copy link
Member

Yeah, that sounds like it would work in principle!

But now there are implementation difficulties; based on my testing, GitHub's search API is too sloppy to match multiword phrases exactly, or even a single URL. Check out how

curl -s -H 'Accept: application/vnd.github.v3+json, application/vnd.github.squirrel-girl-preview+json' "https://api.github.com/search/issues?q=%22https://github.com/grafana/grafana/releases/tag/v3.4.0%22+repo:nixos/nixpkgs"

returns a result in which the URL mentioned is actually https://github.com/grafana/grafana-image-renderer/releases/tag/v3.4.0, even though I used quotes in the search.

That's part of why I suggested a hash; I hope that a string of only alphanumeric characters is safe to search on. We can hash the source URL, and maybe hide it in <!-- --> to minimize clutter for humans?

where
title = U.prTitle env attrPath
search = [interpolate|repo:nixos/nixpkgs $title |]
srcUrlSearch = [interpolate|new src url: $srcUrl |]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a repo:nixos/nixpkgs too, in whatever form it ultimately takes.

when (srcUrl /= T.empty && T.length (openPRReport srcUrlSearchResult) /= 0)
(throwE
( "There might already be an open PR for this update:\n"
<> openPRReport searchResult))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<> openPRReport searchResult))
<> openPRReport srcUrlSearchResult))

@@ -286,7 +288,7 @@ updateAttrPath log mergeBase updateEnv@UpdateEnv {..} attrPath = do
mbLastCommitMsg <- lift $ Git.findAutoUpdateBranchMessage packageName
tell $ Alt mbLastCommitMsg
unless hasUpdateScript do
lift $ checkExistingUpdate log updateEnv mbLastCommitMsg attrPath
lift $ checkExistingUpdate log updateEnv mbLastCommitMsg attrPath oldSrcUrl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right to me—checking for open PRs that target the old src seems useless at best.

I figure we want to do this new check after the rewrites have run in both the hasUpdateScript and not hasUpdateScript cases, so maybe it should be pulled out of checkExistingUpdate and put in its own function.

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

Successfully merging this pull request may close these issues.

Limit PRs to one per meta position
2 participants