[PR #4923] [MERGED] Fix bug when repo remained bare if multiple branches pushed in single push #17549

Closed
opened 2025-11-02 13:59:39 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-gitea/gitea/pull/4923
Author: @SagePtr
Created: 9/12/2018
Status: Merged
Merged: 9/13/2018
Merged by: @lunny

Base: masterHead: issue4919


📝 Commits (2)

  • f228007 Fix bug when repo remained bare if multiple branches pushed
  • 4ca7cfa Merge branch 'master' into issue4919

📊 Changes

1 file changed (+4 additions, -2 deletions)

View changed files

📝 models/action.go (+4 -2)

📄 Description

Fixes #4919

Also closes #3704 (now it's impossible to un-bare repo with tag push)

Bug happened because CommitsBefore method was intended to use in webhooks only, but it was used to determine if pushed branch is not empty (has at least one commit). But in PR https://github.com/go-gitea/git/pull/88 it was changed to ignore commits that have multiple branches (to avoid pushing the same commits twice if other branch is created).

Now i just check this conditions to un-bare repo and set default branch to first pushed branch:
(1) repo is bare
(2) new branch is non-empty (idk if it's possible to push empty branch to bare repo, but extra cautions won't harm)
(3) branch is branch, not tag (which also affects default branch change and makes #3704 impossible too)


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-gitea/gitea/pull/4923 **Author:** [@SagePtr](https://github.com/SagePtr) **Created:** 9/12/2018 **Status:** ✅ Merged **Merged:** 9/13/2018 **Merged by:** [@lunny](https://github.com/lunny) **Base:** `master` ← **Head:** `issue4919` --- ### 📝 Commits (2) - [`f228007`](https://github.com/go-gitea/gitea/commit/f228007a38e0b9855f8eaf0e54ea9fecf6dabb1b) Fix bug when repo remained bare if multiple branches pushed - [`4ca7cfa`](https://github.com/go-gitea/gitea/commit/4ca7cfacb9e0e447fe3226a8eee5bd8d0f63e086) Merge branch 'master' into issue4919 ### 📊 Changes **1 file changed** (+4 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `models/action.go` (+4 -2) </details> ### 📄 Description Fixes #4919 Also closes #3704 (now it's impossible to un-bare repo with tag push) Bug happened because CommitsBefore method was intended to use in webhooks only, but it was used to determine if pushed branch is not empty (has at least one commit). But in PR https://github.com/go-gitea/git/pull/88 it was changed to ignore commits that have multiple branches (to avoid pushing the same commits twice if other branch is created). Now i just check this conditions to un-bare repo and set default branch to first pushed branch: (1) repo is bare (2) new branch is non-empty (idk if it's possible to push empty branch to bare repo, but extra cautions won't harm) (3) branch is branch, not tag (which also affects default branch change and makes #3704 impossible too) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-02 13:59:39 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#17549