mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 19:11:25 +01:00
fix(repo): keep pushes from a cloned fork on the fork
Cloning a fork pointed the default branch at the upstream remote, so a plain `git push` targeted the parent repository. The branch still pulls from upstream, which keeps tea targeting the parent, but now sets branch.<default>.pushRemote=origin so pushes go to the fork. Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
2 files changed
+8
-6
No files matched your search
@@ -278,12 +278,12 @@ func (a *application) cloneRepository(cmd *cobra.Command, t target, item service
|
||||
if _, err := a.gitIn(cmd.Context(), clone, "remote", "add", "--", "upstream", upstream); err != nil {
|
||||
return fmt.Errorf("cloned the fork, but could not add the upstream remote: %w", err)
|
||||
}
|
||||
// The default branch pulls from upstream, but pushes stay on the fork.
|
||||
if branch := item.Parent.DefaultBranch; branch != "" {
|
||||
if _, err := a.gitIn(cmd.Context(), clone, "config", "branch."+branch+".remote", "upstream"); err != nil {
|
||||
return fmt.Errorf("cloned the fork and added upstream, but could not configure branch tracking: %w", err)
|
||||
}
|
||||
if _, err := a.gitIn(cmd.Context(), clone, "config", "branch."+branch+".merge", "refs/heads/"+branch); err != nil {
|
||||
return fmt.Errorf("cloned the fork and added upstream, but could not configure branch tracking: %w", err)
|
||||
for _, setting := range [][2]string{{"remote", "upstream"}, {"merge", "refs/heads/" + branch}, {"pushRemote", "origin"}} {
|
||||
if _, err := a.gitIn(cmd.Context(), clone, "config", "branch."+branch+"."+setting[0], setting[1]); err != nil {
|
||||
return fmt.Errorf("cloned the fork and added upstream, but could not configure branch tracking: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user