fix: <plugin update all> to latest commit on default branch for each plugin#800
fix: <plugin update all> to latest commit on default branch for each plugin#800jthegedus merged 19 commits intoasdf-vm:masterfrom jthegedus:fix/update-all-plugins
Conversation
|
It seems to work (tested in a Docker container with |
|
I should have time to finish this off come this weekend, sorry for the delay. |
|
@jthegedus Can I somehow help you to finish and merge this PR? |
|
@joschi yes please, I think the todo list in this PR is a good starting place |
|
Can probably sneak the fix for #813 in here |
|
Upon testing the current impl it works for cases where the a specified gitref is a branch, but when it is a commit and HEAD goes into a detached state, I am working towards a solution that will support both commit and brach refs (tags will be dealth with later). |
|
Very sorry to @/email here, but this PR has been lingering for over a month and seems to almost address the issue. @jthegedus were you able to make any progress on this and/or still open for help with the commit/HEAD bug? Github repos are increasingly likely to switch or start with "main" more frequently as time goes on and this PR is going to be especially useful for new plugins. I'm trying to implement asdf-awscli and running into this problem myself :) |
|
Newer changes to the code this touches makes this harder to manage. Previously updates were via a full I will spend some time this weekend to finally push this out. That may just be a revert to the older |
|
Thanks so much! It's not a huge blocker, as I can just mirror my changes from main to master for now, but this'll be a nice quality-of-life improvement for future contributions. |
…/asdf into fix/update-all-plugins
|
So for simplicity sake and to get this over the line I decided to go with the @joschi suggestion of
as this is much easier to get working consistently than the other solution I originally committed to
I was unable to get a solution using the "existing branch of sha" soln that also covers the case I outline in this comment #800 (comment) , that's not to say it's not possible, but I could not. As non- The code: specifically the usage of .asdf on master [⇣!] took 1s
➜ asdf plugin update firebase 3a97373
Updating firebase...
fatal: couldn't find remote ref 3a97373
Note: switching to '3a97373'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at 3a97373 fix: shellcheck download URL and shfmt flags
.asdf on master [⇣!] took 1s
➜ asdf plugin update firebase 0496904
Updating firebase...
fatal: couldn't find remote ref 0496904
Previous HEAD position was 3a97373 fix: shellcheck download URL and shfmt flags
HEAD is now at 0496904 feat: firebase tools asdf plugin (#1)
.asdf on master [⇣!]
➜ asdf plugin update firebase
Updating firebase...
Previous HEAD position was 0496904 feat: firebase tools asdf plugin (#1)
Switched to branch 'main'
Your branch is up to date with 'origin/main'.The output of Nonetheless, the solution of checking out the latest sha from the remote's default branch does not result in the issues I outlined in comment #800 (comment) I will ping again for final reviews when ready. |
…or non-branch/tag ref checkouts
|
I discovered you can toggle off specific "git advice" logging per command, so have done so with the It still contains |
| BASE_DIR=$(mktemp -dt asdf.XXXX) | ||
| HOME=$BASE_DIR/home | ||
| ASDF_DIR=$HOME/.asdf | ||
| git clone -o local "$(dirname "$BATS_TEST_DIRNAME")" "$ASDF_DIR" | ||
| git --git-dir "$ASDF_DIR/.git" remote add origin https://github.com/asdf-vm/asdf.git | ||
| mkdir -p "$ASDF_DIR/plugins" | ||
| ASDF_BIN="$ASDF_DIR/bin" | ||
|
|
||
| # shellcheck disable=SC2031 | ||
| PATH=$ASDF_BIN:$ASDF_DIR/shims:$PATH | ||
| install_dummy_plugin | ||
|
|
||
| PROJECT_DIR=$HOME/project | ||
| mkdir $PROJECT_DIR |
There was a problem hiding this comment.
I believe this code was to set the test env asdf root to have a .git dir with the remote set to https://github.com/asdf-vm/asdf.git to enable testing of plugin repo fetching.
I need to put this functionality back in, but think we can put it in the initial setup_asdf_dir function.
|
Though a successful test has run for the core functionality this update adds, I would like to add additional tests before merging for the scenarios I outlined earlier where individual Getting close now. |
|
Thanks for all your work on this @jthegedus, I'll take a look again as soon as I see new changes! |
|
Ready for review @Stratus3D @joschi |
|
I'm fairly confident with this change and will merge in the next day or two. Further testing can be carried out by the people (like myself) who use |
|
Tests pass for me locally on OSX 10.15.7. |
|
@jthegedus @Stratus3D Thanks for taking care of this and testing it! ❤️ |
Summary
As @joschi pointed out in #799
asdf plugin update --alldoes not respect the set gitref with respect to branch names. Since we cannot provide agitrefto each plugin duringupdate --allwe should update to the latest commit on thebranch set by the user ondefault branch of the plugin.plugin addFixes: #799
Fixes: #813
Solution [WIP]
asdf plugin update <name>:asdf plugin update <name> <gitref>:asdf plugin update --all:todo
UNTESTED at this time.tested by @joschi--git-dirusage withfetchandcheckoutwas not tested by myselfasdf plugin updateasdf helpto better describeasdf plugin update --allbehaviourOther Information
--git-dirand--work-treeinstead of subshell +cd.--work-treehas a min git version of1.7.7.2according to https://stackoverflow.com/a/9747584/7911479 This shouldn't increase the required git version forasdfusage AFAICT. According to wikipedia the latest patch for that minor was1.7.12.4released on2012-10-17git --pruneandgit --update-head-ok--git-dir --work-treeis prefered over-Cdue to the lower supportedgitversionCaveats
It is worth pointint out, that this code no longer assumes
masteras the default branch, but does assumeoriginas the default name of the remote.