Poetry: git install doesn't recognize new `main` default branch

Created on 15 Nov 2020  Â·  10Comments  Â·  Source: python-poetry/poetry

poetry add git+https://github.com/AGeekInside/fastapi-jinja.git result in exception since it is tires to checkout master branch.

poetry add git+https://github.com/AGeekInside/fastapi-jinja.git

Updating dependencies
Resolving dependencies...

  CalledProcessError

  Command '['git', '--git-dir', 'C:/Users/n2/AppData/Local/Temp/pypoetry-git-fastapi-jinjau3blv69e/.git', '--work-tree', 'C:/Users/n2/AppData/Local/Temp/pypoetry-git-fastapi-jinjau3blv69e', 'checkout', 'master']' returned non-zero exit status 1.

  at ~\.poetry\lib\poetry\utils\_compat.py:217 in run
      213│                 process.wait()
      214│                 raise
      215│             retcode = process.poll()
      216│             if check and retcode:
    → 217│                 raise CalledProcessError(
      218│                     retcode, process.args, output=stdout, stderr=stderr
      219│                 )
      220│         finally:
      221│             # None because our context manager __exit__ does not use them.

as the default branch name has changed, poetry should both accept main and master.

the workaround is

  1. poetry add git+https://github.com/AGeekInside/fastapi-jinja.git#main
  2. pip install git+https://github.com/AGeekInside/fastapi-jinja.git
Bug Good First Issue Triage

Most helpful comment

Poetry should simply not specify a branch by default. This should then default to whatever is the server default and this should adhere to expected behaviour. Might require removing this "master is default" assumption at multiple points in the code. PR welcome.

As for the error messages. There is very little we can do here at the moment since the git command is being processed as a subprocess call and errors can happen at various nested levels. Moving to a native python library will help with this in the future. As for immideate improvements, if you can identify any easy wins within the current error handling, PR is welcome, but maybe open another issue for that.

All 10 comments

I could create a PR if you like.

Based on what clue should it be decided to go for master or main?

the default branch name has changed

Where? In git, in github, in your own projects?

Can the default branch name be auto-detected somehow?

@sinoroc github has changed for all newly created repo. https://www.zdnet.com/article/github-to-replace-master-with-main-starting-next-month/

My impulse answer would be to check (or to try-catch) starting for 'master' then 'main'.

or, we can derive the implementation from pip.

One thing to note also that, the verbose message of the error is not really helpful if not looking carefully. The verbose message should tell the user about the cause that the target branch is not exist.

Poetry should simply not specify a branch by default. This should then default to whatever is the server default and this should adhere to expected behaviour. Might require removing this "master is default" assumption at multiple points in the code. PR welcome.

As for the error messages. There is very little we can do here at the moment since the git command is being processed as a subprocess call and errors can happen at various nested levels. Moving to a native python library will help with this in the future. As for immideate improvements, if you can identify any easy wins within the current error handling, PR is welcome, but maybe open another issue for that.

The only meaningful direct reference in code I could find is there:

        if not any([branch, tag, rev]):
            # If nothing has been specified, we assume master
            branch = "master"

The rest of the code should probably be adapted to work when branch, tag and rev are all None.

Is this still open? I could try to tackle this as my first issue.

Is this still open? I could try to tackle this as my first issue.

Yes, as far as I can tell, there is no PR yet so you'd be first.

This is definitely a dumb question, but I need to work on poetry-core, right? Not in the poetry repo.

I need to work on poetry-core, right? Not in the poetry repo.

As far as I can tell, yes. At least, I would start with _poetry-core_. Then it will show if some more modifications are needed in _poetry_ or not.

Was this page helpful?
0 / 5 - 0 ratings