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

error on add/import for implicit branch main #113

Open
KiaraGrouwstra opened this issue Feb 5, 2025 · 5 comments
Open

error on add/import for implicit branch main #113

KiaraGrouwstra opened this issue Feb 5, 2025 · 5 comments

Comments

@KiaraGrouwstra
Copy link

KiaraGrouwstra commented Feb 5, 2025

using npins 0.2.4, npins import-flake...

works for inputs with implicit branch master:

    flake-compat.url = "github:edolstra/flake-compat";
[INFO ] Importing flake-compat

yet for inputs with implicit branch main fails:

    flake-parts.url = "github:hercules-ci/flake-parts";
[INFO ] Importing flake-parts
[ERROR] Failed to import pin 'flake-parts'
[ERROR] Couldn't fetch the latest commit
[ERROR]         git ls-remote output is empty. Are you sure 'refs/heads/master' exists? Note: If you want to tag a revision, you need to also specify a branch ('--branch').

something similar happens when adding such entries separately (without specifying branch):

npins add github hercules-ci flake-parts
[INFO ] Adding 'flake-parts' …
Error: Failed to fully initialize the pin

Caused by:
    Repository has no matching release tags

(a similar symptom also seemed reported at #100 (comment))

expected behavior: either default branch should just work

@KiaraGrouwstra KiaraGrouwstra changed the title import-flake fails for inputs with implicit branch not named master error on add/import when implicit branch main Feb 5, 2025
@piegamesde
Copy link
Collaborator

CC @stuebinm

@stuebinm
Copy link
Contributor

stuebinm commented Feb 6, 2025

oh dear.

afaict, there's two levels of unexpected things here: when I first wrote the flake importer, I assumes Nix would default to master rather than the repository's default branch, and that causes your npins import-flake to fail. Here, at least, the culprit is obvious, as is the fix: npins should run git ls-remote --symref <url> HEAD to find the default branch, if none was given as an argument. Perhaps I'll find the time to fix that soon-ish, if nobody else does (but I'm a bit tight on free time currently, so no outright promises).

The second error is unrelated, subtler, and (to me) much more surprising: npins is looking for a release tag, rather than a branch, and finding none (which is, as such, correct, as that repository has none, whereas flake-compat does, and hence for that this works). But I'm not sure if this is also the intended behaviour?

@piegamesde
Copy link
Collaborator

Let's focus on the import-flake issue, as in my eyes the failure of npins add github hercules-ci flake-parts is correct: npins add looks for releases unless a branch is specified. The UX of that may be changed of course, but to me things are working as intended..

@KiaraGrouwstra KiaraGrouwstra changed the title error on add/import when implicit branch main error on add/import for implicit branch main Feb 8, 2025
@stuebinm
Copy link
Contributor

(just in case it got missed: i opened a PR for this #114@KiaraGrouwstra can you try if it works for you?)

@KiaraGrouwstra
Copy link
Author

@stuebinm thanks, #114 addresses this! 😌

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

No branches or pull requests

3 participants