Add command to backup the stack to the remote in case machine failure
@chillbrodev mentioned in chat
had a random idea of a backup feature where you could use gps backup and it creates remote branches of all your patches even if there are patch dependencies. I do this when Im about to travel and have a few loose patches for those “just in case fears”.
Maybe this just becomes in option on sync -all for sync all or something.
I am not sure how valuable I really feel this command is.
The value is quite small and niche. Its more of a feature that is rarely used though I see how it could be abused to create patch PRs with dependencies. CI would fail the PR since it couldn't build it and maybe it makes sense to inject the word "BACKUP" or something into the commit. Thinking out loud here.
Well if there are conflicts in the cherry-picking it wouldn't be possible to sync the patch. Syncing only works for patches that are independent enough that they can be cherry-picked.
If you want to back your stack up, it might make more sense to create a stack specific branch and force pushes the stack up to it
Ah this might be more what I am looking for. The Backup Branch would work. We can close this then.
It still might be nice to have this to help hold the Patch Stack abstraction and make it so you don't have to think about the fact that it is a branch. Also I don't think it is totally straight forward how you would do it.
If we take the example of main as your local branch and it is a tracking branch of the upstream origin/main.
You wouldn't want to push main up to origin/main because that would effectively integrate all of the patches in your stack. Instead we would probably want to do the following.
- create a new branch
ps/stack-backups/main(or something similar) that points to the head commit of the localmainbranch - push the
ps/stack-backups/mainbranch up to the remote associated with the stack, in this caseoriginso it would then haveorigin/ps/stack-backups/main
At this point the entire stack would be backed up.
Now we probably also need to think about uniqueness across users because once we push remote if two users do this they would overwrite each others branches. So the branches somehow need to have something user unique in the branch naming.
But I think in theory that would work and I think it is enough of a pain to have to do this manually with git that it would be nice to implement it.
I think the biggest question in terms of implementation is figuring out where we get user unique identifier. I guess we could pull the user email out of the .gitconfig and hash it to get a unique identifier we can use in the branch name.
so the branch naming would be something maybe like ps/stack-backups/<user-unique-hash>/main.
Now that gps no longer has state tracking and it does pure state computation from the Git tree. This likely needs to be rethought.
The goto solution for me is to branch and push to a remote. Especially if I need some patches on another matchine. gps could do this with say gpp bu which would create a patch series for the entire stack and push it to a special branch, say with time and date in the name.