Skip to content

Git update_repo fails when there are only untracked files #395

Closed

Description

@jfpedroza

Currenly when using vcspull sync, and a repo has untracked files and no other changes, the command fails with something like

File "/home/jhon/.local/lib/python3.10/site-packages/vcspull/cli/sync.py", line 104, in update_repo
  r.update_repo(set_remotes=True)  # Creates repo if not exists and fetches
File "/home/jhon/.local/lib/python3.10/site-packages/libvcs/projects/git.py", line 465, in update_repo
  self.run(["stash", "pop", "--index", "--quiet"])
File "/home/jhon/.local/lib/python3.10/site-packages/libvcs/projects/base.py", line 154, in run
  return run(
File "/home/jhon/.local/lib/python3.10/site-packages/libvcs/cmd/core.py", line 211, in run
  raise exc.CommandError(output=output, returncode=code, cmd=cmd)
libvcs.exc.CommandError: Command failed with code 1: git stash pop --index --quiet)

That is because git status returns output including the untracked files while git stash save doesn't have the -u flag and so no stash is actually created.

To fix the problem, one of these should be performed:

  • Add --untracked-files=no to git status
  • Add --include-untracked to git stash save
  • Check if a stash was actually created before trying to pop

Activity

  1. jfpedroza commented on Sep 23, 2022

    @jfpedroza
    ContributorAuthor

    I would like to fix this. Which of the options would prefer?

  2. tony commented on Sep 23, 2022

    @tony
    Member

    @jfpedroza Hi

    I'm not sure of the consequences at scale. All look appetizing, and look like they'd make the syncing more robust.

    I would accept a PR with any of those.

    And if you wrote a test, that'd be legendary.

    P.S. I am going to be making sweeping improvements to this library over the coming months - as well as vcspull. I apologize for how crusty the internals are. They will improve, markedly.

  3. jfpedroza commented on Sep 24, 2022

    @jfpedroza
    ContributorAuthor

    So, I went and cloned everything and set up the projects.

    It turns out vcspull points to libvcs 0.14 which looks like a different project than master and vcspull won't run with it.

    Should I check the changes against the mypy-annotations branch?

  4. jfpedroza commented on Sep 24, 2022

    @jfpedroza
    ContributorAuthor

    I got it running with that branch and adding the vcs key to the config entries.

  5. tony commented on Sep 24, 2022

    @tony
    Member

    @jfpedroza

    You've ran into a temporary issue. That's where I'm doing work at the moment - and could probably break within minutes of you making a change (assuming I'm awake)

    I'll give you instructions to where the stable branches are

    Sorry about that: Backstory: The metaphorical "big dig" is happening, where a major refactor on both sides are being reconciled

  6. tony commented on Sep 24, 2022

    @tony
    Member

    libvcs branch: v0.13.x
    vcspull branch: master

    Is this any better?

    Or, I can notify you when mypy-annotations is completed (in which case both master branches will work together)

  7. tony commented on Sep 24, 2022

    @tony
    Member

    I updated both of these:

    • libvcs: v0.13.x

      If you try this locally, does py.test work?

      My changes: Dev package updates, fixed tests on CI (using git --version at 2.27.3)

    • vcspull: master

      README now points to libvcs v0.13.x

    When pointing to a live libvcs from vcspull:

    Clone libvcs also, then checkout v0.13.x:

    git checkout v0.13.x

    In vcspull master (or your branch based off master):

    pip install -e ~/path/to/libvcs
  8. tony commented on Sep 24, 2022

    @tony
    Member

    @jfpedroza Due to the state of limbo you've happened upon this issue - I am also happy to PR it on your behalf.

    (for both backport and new version of libtmux)

  9. jfpedroza commented on Sep 25, 2022

    @jfpedroza
    ContributorAuthor

    I checked out the v0.13.x branch and got this error. Already deleted the virtual env and created it again.

    image

  10. tony commented on Sep 25, 2022

    @tony
    Member

    @jfpedroza Thank you!

    poetry self --version
    python -V
    py.test --version

    What do those look like?

  11. jfpedroza commented on Sep 25, 2022

    @jfpedroza
    ContributorAuthor
    poetry self --version
    Poetry (version 1.2.1)
    
    python -V
    Python 3.10.7
    
    poetry run py.test --version
    pytest 7.1.3
    
  12. jfpedroza commented on Sep 25, 2022

    @jfpedroza
    ContributorAuthor

    I just realized. Do the tests require Subversion and Mercurial to be installed? Because I absolutely don't have those.

    Although, all tests in master pass.

  13. tony commented on Sep 25, 2022

    @tony
    Member

    Do the tests require Subversion and Mercurial to be installed?

    Those should be skipped automatically if you don't have the binary

    I will take a closer look now

  14. tony commented on Sep 25, 2022

    @tony
    Member

    @jfpedroza If you fetch the latest from v0.13.x (ff9247b), is it any better?

  15. jfpedroza commented on Sep 25, 2022

    @jfpedroza
    ContributorAuthor

    Tests pass now :D

  16. tony commented on Sep 25, 2022

    @tony
    Member

    @jfpedroza Brilliant!

  17. tony commented on Sep 25, 2022

    @tony
    Member

    FYI I will go to sleep for now and be around in the morning tomorrow 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions