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

Library update fails with git provider and fixed sync-version #721

Open
jfrimmel opened this issue Jan 17, 2025 · 1 comment · May be fixed by #724
Open

Library update fails with git provider and fixed sync-version #721

jfrimmel opened this issue Jan 17, 2025 · 1 comment · May be fixed by #724

Comments

@jfrimmel
Copy link
Contributor

I've noticed a problem when using fixed library versions in conjunction with libraries, that should be updated. This can reproduced with the current master (commit b604f53d):

  • create a temporary virtual environment and install the latest fusesoc
    mkdir tmp && cd tmp
    python -m venv .venv
    . .venv/bin/activate
    pip install --force-reinstall git+https://github.com/olofk/fusesoc.git
  • reproduce the issue
    $ fusesoc library add https://github.com/fusesoc/fusesoc-generators --sync-version v0.1.3
    INFO: Cloning library into fusesoc_libraries/fusesoc-generators
    <snip>
    INFO: Checkout out fusesoc-generators at version v0.1.3
    $ fusesoc library update
    INFO: fusesoc-generators : Updating...
    INFO: Checkout out fusesoc-generators at version v0.1.3
    You are not currently on a branch.
    Please specify which branch you want to merge with.
    See git-pull(1) for details.
    
        git pull <remote> <branch>
    
    ERROR: fusesoc-generators : Failed to update library: "git -C fusesoc_libraries/fusesoc-generators pull" exited with an error code. See stderr for details.

I think this can be solved rather easily, by replacing git pull with git fetch when a sync-version is requested. I might open a PR for this soon.

@jfrimmel
Copy link
Contributor Author

The fix is indeed simple:

diff --git a/fusesoc/provider/git.py b/fusesoc/provider/git.py
index cbcf3a1..bb1af4b 100644
--- a/fusesoc/provider/git.py
+++ b/fusesoc/provider/git.py
@@ -38,7 +38,8 @@ class Git(Provider):
 
     @staticmethod
     def update_library(library):
-        git_args = ["-C", library.location, "pull"]
+        download_option = "pull" if not library.sync_version else "fetch"
+        git_args = ["-C", library.location, download_option]
         try:
             Git._checkout_library_version(library)
             Launcher("git", git_args).run()

I need to add a test for it. After that, I'll submit a pull request.

jfrimmel added a commit to jfrimmel/fusesoc that referenced this issue Jan 18, 2025
See olofk#721 for context. This simply uses `git fetch` instead of `git pull`
if a specific version is requested. This is a kind of hacky solution,
since this won't work if somebody removes the `sync-version` from the
`fusesoc.conf`-file (in that case, the code will use `git pull` again,
which will fail as before). Since this usecase is not that common, this
commit should be enough for now.
jfrimmel added a commit to jfrimmel/fusesoc that referenced this issue Jan 18, 2025
See olofk#721 for context. This simply uses `git fetch` instead of `git pull`
if a specific version is requested. This is a kind of hacky solution,
since this won't work if somebody removes the `sync-version` from the
`fusesoc.conf`-file (in that case, the code will use `git pull` again,
which will fail as before). Since this usecase is not that common, this
commit should be enough for now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant