Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Pshy0 opened this issue Aug 6, 2023 · 8 comments
Open

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

Pshy0 opened this issue Aug 6, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@Pshy0
Copy link
Contributor

Pshy0 commented Aug 6, 2023

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
Copy link
Contributor Author

Pshy0 commented Aug 6, 2023

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

@Pshy0
Copy link
Contributor Author

Pshy0 commented Aug 6, 2023

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.

@warp-core
Copy link
Contributor

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
Copy link
Contributor

#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.

@Pshy0
Copy link
Contributor Author

Pshy0 commented Aug 6, 2023

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.

@MCOfficer
Copy link
Collaborator

MCOfficer commented Aug 6, 2023

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 MCOfficer changed the title Autoupdate is failing. Autoupdate: Don't fail if assumed default branch doesn't exist Aug 6, 2023
@MCOfficer MCOfficer added the bug Something isn't working label Aug 6, 2023
@Pshy0
Copy link
Contributor Author

Pshy0 commented Aug 10, 2023

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?)

@TheGiraffe3
Copy link
Contributor

What’s the status on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants