Skip to content
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

Mirroring of external repository does not work after rebase #6783

Closed
samangh opened this issue Apr 27, 2019 · 4 comments · Fixed by #6824
Closed

Mirroring of external repository does not work after rebase #6783

samangh opened this issue Apr 27, 2019 · 4 comments · Fixed by #6824
Labels

Comments

@samangh
Copy link

samangh commented Apr 27, 2019

  • Gitea version (or commit ref): 1.8.0 built with go1.12.4
  • Git version: 2.21.0
  • Operating system: Linux Debian
  • Database (use [x]):
    • [ x] MySQL
  • Can you reproduce the bug at https://try.gitea.io:
    • [ x] Yes

Description

If gitea is mirroring an external repository and the external repository undergoes a rebase or a force push (so that the histories diverge), then the mirrored repository fails to show those changes.

Steps to reproduce:

  1. Create a repository with an inital commit on GitHub
  2. Mirror this with gitea
  3. Reword the initial commit, and force push up to Github
  4. Observe that the changes are not shown on the master branch of the mirrored repository

For an example please see https://try.gitea.io/samangh/teset, which is supposed to be a mirror of https://github.com/samangh/test.

@lunny lunny added the type/bug label Apr 28, 2019
@yasuokav
Copy link
Contributor

yasuokav commented May 1, 2019

Have you ever update the mirror settings on the settings page?

@yasuokav
Copy link
Contributor

yasuokav commented May 1, 2019

My mirror repo is getting weird after #6593 merged, can you check it? @zeripath

The mirror is unable to update the new commits to the proper branch after I update the mirror settings.

xxxxx.git/config:

before:

[core]
    ...
[remote "origin"]
	url = https://xxxx
	fetch  = +refs/*:refs/*
	mirror = true

after mirror settings updated:

[core]
    ...
[remote "origin"]
	url = https://xxxx
	fetch = +refs/heads/*:refs/remotes/origin/*

gitea/models/repo_mirror.go

Lines 123 to 133 in eb8632b

func (m *Mirror) SaveAddress(addr string) error {
repoPath := m.Repo.RepoPath()
// Remove old origin
_, err := git.NewCommand("remote", "remove", "origin").RunInDir(repoPath)
if err != nil && !strings.HasPrefix(err.Error(), "exit status 128 - fatal: No such remote ") {
return err
}
_, err = git.NewCommand("remote", "add", "origin", addr).RunInDir(repoPath)
return err
}

@samangh
Copy link
Author

samangh commented May 1, 2019

Have you ever update the mirror settings on the settings page?

No. I've just tried to manually mirror things by pressing the 'Sync' button.

Interesting, this is not 100% reproducible. I just setup another mirror on my local gitea server and the mirroring worked fine even with rebases. However, the example mirror that I setup on https://try.gitea.io/samangh/teset is still broken.

@zeripath
Copy link
Contributor

zeripath commented May 1, 2019

Hmm... I wonder if this needs to be

_, err = git.NewCommand("remote", "add", "origin", "--mirror=fetch", addr).RunInDir(repoPath)

@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants