-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Delete local branch when repo branch is deleted #6497
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
Conversation
Signed-off-by: jolheiser <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #6497 +/- ##
=========================================
Coverage ? 40.41%
=========================================
Files ? 404
Lines ? 54140
Branches ? 0
=========================================
Hits ? 21883
Misses ? 29240
Partials ? 3017
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
https://github.com/go-gitea/gitea/blob/master/modules/uploader/update.go
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm gonna approve as this is a bug fix, but I'm gonna look at removing this unnecessary cloning from the codebase.
Take a look at: #6505 |
@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 |
@zeripath Once your PR is merged I will look at submitting a new PR implementing those changes in this area. (Unless your PR just removes these changes as part of the conversion) |
Fixes #6490
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.