-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Check if branch exists before updating #5362
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
base: V3/develop
Are you sure you want to change the base?
Conversation
Can we just check if the given revision (which is saved in Config and therefore doesn't depend on the current, possibly invalid state of the repository) is a branch (I assume that is probably possible to do with git)? I think that's the only thing that isn't constant (and is therefore the only thing that Downloader can update)? Technically, tags can be modified too but I don't think we need to support it right now, especially that we don't even properly support when people force push to the branch. |
This sounds like a good idea but I am seeing one edge case, if the user manually updates the repo (for whatever reason) the commit in the config is no longer the latest commit of the branch. I am unsure if this is something that needs to be tackled to prevent PEBKAC or if modifying red data outside of red is unsupported
. |
|
having had a bit to think about this, what about when a tag and branch are both on the same commit? |
It probably doesn't matter. When you add a repo, you pass a named reference (or omit it, in which case the default branch is used and saved) which is saved with Config: {
"170708480":
{
"GLOBAL":
{
"repos":
{
"Fox-V3": "master",
"aika": "v3",
"preda": "master",
"trusty": "master",
"kenny": "v3-cogs",
"jack-private": "v3",
"draper": "master",
"ax": "V3",
"laggron": "v3",
"PR4086": "master",
"sinbad": "v3",
"me-bounty": "main",
"palmtree5": "redv3-rewrites",
"weird": "master",
"flame": "master"
}
}
}
}The current state of the repository doesn't really matter as we have the indication of whether we're dealing with a branch or something else based on this alone. We just need to detect whether the given name is a branch name which can be done by adding |
4fa7c2b to
192cc80
Compare
192cc80 to
c38b6fa
Compare
|
right, ignore me forgetting to run black I've changed the approach to the one you suggested: checking if the branch exists before updating. This is implemented in a naive way and simply uses |
Checks is the branch used for the repo exists using
git show-ref --quiet --verifybefore trying to updatecloses #3397