summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-03-25 17:50:18 -0400
committerUnknwon <u@gogs.io>2015-03-25 17:50:18 -0400
commitab730a91f05b58ed18bb77c545c6a120ab96c531 (patch)
tree90765b02be55c55cf3b271bf5d5048ebe01fc955
parentc5c5aac7a5a0c7a39720334f0f432c3939a2da52 (diff)
downloadgitea-ab730a91f05b58ed18bb77c545c6a120ab96c531.tar.gz
gitea-ab730a91f05b58ed18bb77c545c6a120ab96c531.zip
#1120 #1132 mirror info not updated when transfer mirro repo
-rw-r--r--models/repo.go29
1 files changed, 25 insertions, 4 deletions
diff --git a/models/repo.go b/models/repo.go
index 5412ca8f82..91bb0d710b 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -283,9 +283,9 @@ type Mirror struct {
NextUpdate time.Time
}
-func GetMirror(repoId int64) (*Mirror, error) {
+func getMirror(e Engine, repoId int64) (*Mirror, error) {
m := &Mirror{RepoId: repoId}
- has, err := x.Get(m)
+ has, err := e.Get(m)
if err != nil {
return nil, err
} else if !has {
@@ -294,11 +294,20 @@ func GetMirror(repoId int64) (*Mirror, error) {
return m, nil
}
-func UpdateMirror(m *Mirror) error {
- _, err := x.Id(m.Id).Update(m)
+// GetMirror returns mirror object by given repository ID.
+func GetMirror(repoId int64) (*Mirror, error) {
+ return getMirror(x, repoId)
+}
+
+func updateMirror(e Engine, m *Mirror) error {
+ _, err := e.Id(m.Id).Update(m)
return err
}
+func UpdateMirror(m *Mirror) error {
+ return updateMirror(x, m)
+}
+
// MirrorRepository creates a mirror repository from source.
func MirrorRepository(repoId int64, userName, repoName, repoPath, url string) error {
_, stderr, err := process.ExecTimeout(10*time.Minute,
@@ -697,6 +706,18 @@ func TransferOwnership(u *User, newOwnerName string, repo *Repository) error {
return fmt.Errorf("transferRepoAction: %v", err)
}
+ // Update mirror information.
+ if repo.IsMirror {
+ mirror, err := getMirror(sess, repo.Id)
+ if err != nil {
+ return fmt.Errorf("getMirror: %v", err)
+ }
+ mirror.RepoName = newOwner.LowerName + "/" + repo.LowerName
+ if err = updateMirror(sess, mirror); err != nil {
+ return fmt.Errorf("updateMirror: %v", err)
+ }
+ }
+
// Change repository directory name.
if err = os.Rename(RepoPath(owner.Name, repo.Name), RepoPath(newOwner.Name, repo.Name)); err != nil {
return fmt.Errorf("rename directory: %v", err)