endless-sky-plugins icon indicating copy to clipboard operation
endless-sky-plugins copied to clipboard

Autoupdate: Don't fail if assumed default branch doesn't exist

Open Pshy0 opened this issue 2 years ago • 8 comments

The Autoupdate job is failing on manifests/Cromha Expansion.yaml.

image

image

The main branch of this plugin's repository is called "main", not "master".

On the long run, I would suggest that failing to update a plugin should not cause the whole job to abort, it should instead try to update the other plugins, and only raise the errors that happened at the end. This way, if an error is limited to a plugin, maintenance of the endless-sky-plugins repository would not be required to keep it updating the other plugins.

Pshy0 avatar Aug 06 '23 21:08 Pshy0

This would happen if a plugin updating from commits does not have the branch name configured: image image

Pshy0 avatar Aug 06 '23 21:08 Pshy0

According to ES's RFC 0001:

  • branch: Allows for special branches to be used when type is commit. If omitted, the default branch will be used instead.

This would mean the issue is not with the manifest, but with the update script assuming the default branch is master, while it may not be.

Pshy0 avatar Aug 06 '23 21:08 Pshy0

I've updated that manifest file to refer to the main branch so it should work the next time the autoupdate job runs.

warp-core avatar Aug 06 '23 21:08 warp-core

https://github.com/endless-sky/endless-sky-plugins/issues/1004 The same thing was happening with another plugin manifest as well. We can't currently just use the default branch, as far as I know.

warp-core avatar Aug 06 '23 21:08 warp-core

You can get the default branch using github's api like this: https://api.github.com/repos/Pshy0/es-ruin-the-fun There is a "default_branch" field.

Pshy0 avatar Aug 06 '23 21:08 Pshy0

We should try master, then main, then (if its on github) the api. Autoupdate is supposed to be independant of git hoster, but as a workaround to minimize errors it's ok. As last resort there's still the branch field warp just used.

MCOfficer avatar Aug 06 '23 21:08 MCOfficer

This script gets the repository branch pointing to the same commit than HEAD:

#!/bin/env sh
HEAD_COMMIT=$(git ls-remote $1 HEAD | head -n 1 | sed -e 's|\t.*/\?HEAD$||')
HEAD_BRANCH=$(git ls-remote --heads $1 | grep "$HEAD_COMMIT" | head -n 1 | sed 's|[0-9a-f]\{40\}\trefs/heads/||')
echo "$HEAD_BRANCH"

When I change the default branch of one of my github repositories, the change is seen instantly: image image

Other tests: image image image

Framagit: image

Gitlab: image image

NOTE: you can certainly do that after cloning, without git ls-remote (shouldn't you be on the right branch after cloning anyway?)

Pshy0 avatar Aug 10 '23 12:08 Pshy0

What’s the status on this?

TheGiraffe3 avatar Jun 16 '24 12:06 TheGiraffe3