feature: check for existing updates with same src url #316
Conversation
|
Wouldn't this solution mean that a PR for Maybe a better check would be to do something like hashing the diffs created? |
|
@rhendric Good point, how about how it is now where it checks for a duplicate |
|
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 returns a result in which the URL mentioned is actually 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 |
| where | ||
| title = U.prTitle env attrPath | ||
| search = [interpolate|repo:nixos/nixpkgs $title |] | ||
| srcUrlSearch = [interpolate|new src url: $srcUrl |] |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
| <> openPRReport searchResult)) | |
| <> openPRReport srcUrlSearchResult)) |
| tell $ Alt mbLastCommitMsg | ||
| unless hasUpdateScript do | ||
| lift $ checkExistingUpdate log updateEnv mbLastCommitMsg attrPath | ||
| lift $ checkExistingUpdate log updateEnv mbLastCommitMsg attrPath oldSrcUrl |
There was a problem hiding this comment.
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.
|
Thought of a possible alternative to this, get the src.url of the package when it is read into the supervisor database and then try to drop the duplicates from the update queue? pseudocode example for getting the src.url: diff --git a/hosts/build02/supervisor.py b/hosts/build02/supervisor.py
index 68e0c160..ee6f556c 100644
--- a/hosts/build02/supervisor.py
+++ b/hosts/build02/supervisor.py
@@ -692,6 +692,23 @@ class FetcherDataWatcher:
return
self._storage.delete_fetcher_run(name, run_started)
+ def get_src_url(attr_path: str) -> str:
+ try:
+ prefix = "/var/cache/nixpkgs-update/worker/nixpkgs"
+ nix = subprocess.run(
+ [
+ "nix",
+ "eval",
+ "-f",
+ f"{prefix}",
+ f"{attr_path}.src.url",
+ ],
+ )
+ output = nix.stdout.strip()
+ return output.removeprefix(prefix)
+ except subprocess.CalledProcessError:
+ return "no_src_url"
+
def _read_fetcher_lines(
self, file: TextIO
) -> Generator[None, None, list[tuple[str, str]]]:
@@ -716,7 +733,7 @@ class FetcherDataWatcher:
continue
match line.strip().split(" ", maxsplit=1):
case [attr_path, payload]:
- entries.append((attr_path, payload))
+ entries.append((attr_path, payload, get_src_url(attr_path)))
case _:
print(f"Unexpected line in {file.name!r}: {line!r}")
|
fixes #315
@rhendric interested in reviewing this?