pulsar-edit / ppm

Pulsar Package Manager
MIT License
35 stars 13 forks source link

`ppm upgrade` doesn't work for git-installed packages without a `master` branch #55

Closed savetheclocktower closed 1 year ago

savetheclocktower commented 1 year ago

Thanks in advance for your bug report!

What happened?

I was wondering why some of my git-installed packages were able to be upgraded — both within the editor and via ppm upgrade — and some were not. I managed to track down what I think is the answer: ppm upgrade checks a hard-coded refs/heads/master, and many newer repos use main as the default branch.

GitHub changed the default on new repos back in 2020, but never updated apm accordingly.

I suppose the simplest fix would be to do repo.getUpstreamBranch('refs/heads/main') || repo.getUpstreamBranch('refs/heads/master'), so that’s probably what I’ll do unless someone has a better suggestion.

Pulsar version

1.101.0-beta

Which OS does this happen on?

🍎 macOS

OS details

11.7.3

Which CPU architecture are you running this on?

64-bit(x86_64)

What steps are needed to reproduce this?

I don't expect anyone to do this, but here we go:

  1. Create a GitHub repo with main as its default branch. Put a skeleton package in it — perhaps a sample package from the Flight Manual.
  2. Install it with ppm install [github username]/[repo name].
  3. Land a trivial update to the package on main.
  4. Attempt to upgrade it with ppm upgrade [repo name]; nothing will happen.

Additional Information:

No response

savetheclocktower commented 1 year ago

From experimentation, changing the line to

sha = repo.getReferenceTarget(repo.getUpstreamBranch(repo.getHead()))

also appears to work, but I wonder why they wouldn't have simply done that in the first place.

confused-Techie commented 1 year ago

From experimentation, changing the line to

sha = repo.getReferenceTarget(repo.getUpstreamBranch(repo.getHead()))

also appears to work, but I wonder why they wouldn't have simply done that in the first place.

This looks like a fantastic solution! And if that works we should go for it.

No clue why it wouldn't be used originally, but there's been a few things we found like that. Guess hindsight is always 2020, when we now know that master branches can change and won't always be master as they were for years when that was originally written.