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

Fix package position links #242

Merged
merged 1 commit into from Dec 2, 2020
Merged

Fix package position links #242

merged 1 commit into from Dec 2, 2020

Conversation

ncfavier
Copy link
Member

@ncfavier ncfavier commented Dec 1, 2020

Splitting at the 44th character means leaving the source/ part which is not part of GitHub nixpkgs URLs. All "Nix expression" links in the package search are currently broken because of this.

This fix strips the first three path components instead (/nix/store/...-source).

@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2020

@ncfavier
Copy link
Member Author

ncfavier commented Dec 1, 2020

Oops, I tried bumping the version in VERSION to trigger the import but now it 404s. I'm just gonna wait.

@ncfavier
Copy link
Member Author

ncfavier commented Dec 1, 2020

Noted.

@garbas
Copy link
Member

garbas commented Dec 2, 2020

@ncfavier Sorry I wrote to fast before. The VERSION change lets us test - alongside existing search index. Most of the time I only used this when index schema changed and bigger changes. But we do have to run the import manually.

@ncfavier
Copy link
Member Author

ncfavier commented Dec 2, 2020

Ok, I assume it's something you have to do?

@garbas
Copy link
Member

garbas commented Dec 2, 2020

yes, sadly, It would be nice to automate this somehow.

@@ -462,7 +462,7 @@ def gen():

position = data["meta"].get("position")
if position and position.startswith("/nix/store"):
position = position[44:]
position = position.split("/", 4)[-1]
Copy link
Member

Choose a reason for hiding this comment

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

I think some time ago this was actually working. but then something changed in nixpkgs and source/ was added. It think we need to be a little more defensive here. I would only remove source/ and nothing else. We definetly dont want to rely on structure here.

position = position[44:]
if position.startswith('source/'):
    position = position[len('source/'):]

or something similar

Copy link
Member Author

Choose a reason for hiding this comment

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

But then things will break again if source/ changes to src/ or whatnot. I think we can reasonably rely on the fact that it will always look like /nix/store/hash-name/actual_path_in_nixpkgs, and therefore stripping the first three path components should be enough.

@garbas
Copy link
Member

garbas commented Dec 2, 2020

I'll import the channels manually and then merge this.

@garbas garbas merged commit 27ff900 into master Dec 2, 2020
@garbas garbas deleted the fix-package-position-links branch December 2, 2020 12:53
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.

None yet

2 participants