Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Delete local branch when repo branch is deleted #6497
Currently, when creating a branch from the web UI (not a commit, directly from the branch dropdown), Gitea creates the branch in its local cache and pushes it to the real repo.
When the branch is deleted, it was not being deleted from the local cache and if a branch of the same name is created, Gitea panics because the local repo already has a branch with that name.
Since the Gitea's tmp directory is deleted on startup, the only (current) way to clear the local repo cache is to restart Gitea.
@@ Coverage Diff @@ ## master #6497 +/- ## ========================================= Coverage ? 40.41% ========================================= Files ? 404 Lines ? 54140 Branches ? 0 ========================================= Hits ? 21883 Misses ? 29240 Partials ? 3017
zeripath left a comment
The local cache needs to go. Do we even need it still?
I cannot believe that we're actually requiring a full clone to just do a branch creation - particularly a full clone we keep around.
Can't we follow the technique in
Where we just do a thin clone, create an index from the appropriate old branch and then push it as the new branch. We probably don't even need an index - We could just push our HEAD to the new branch.
In fact I wouldn't be surprised if we couldn't just do a push from an empty place to create a new branch. Would have to look at the documentation for git push.
A branch is simply a file with a hash to a tree object. It's nothing magical. The only benefit with pushing is that you make sure hooks etc will run.
If I do follow how the uploader does it, should I take that code and put it somewhere else (perhaps a new module, or in
I could just use the existing code, but it would seem odd to use the
@zeripath Even if it's out of scope of this PR, yes you can push a new branch without checking it out.
The form of the git push command which will permit to do so is
From the directory of the gitea bare repository (/path/to/gitea-repositories/username/repo.git) you can do
This will trigger git hooks