]> source.dussan.org Git - gitea.git/commitdiff
bug fixed for migrate and fixed #141
authorlunnyxiao <xiaolunwen@gmail.com>
Tue, 2 Sep 2014 03:57:06 +0000 (11:57 +0800)
committerlunnyxiao <xiaolunwen@gmail.com>
Tue, 2 Sep 2014 03:57:06 +0000 (11:57 +0800)
models/repo.go

index 4703696678d20fa3dca8d1a748ed32d6f3d7dce1..105e8eecda6fefbd2512981cf8ac4f4c3301055a 100644 (file)
@@ -277,7 +277,7 @@ func MirrorUpdate() {
 
 // MigrateRepository migrates a existing repository from other project hosting.
 func MigrateRepository(u *User, name, desc string, private, mirror bool, url string) (*Repository, error) {
-       repo, err := CreateRepository(u, name, desc, "", "", private, mirror, false)
+       repo, err := CreateRepository(u, name, desc, "", "", private, true, false)
        if err != nil {
                return nil, err
        }
@@ -307,8 +307,15 @@ func MigrateRepository(u *User, name, desc string, private, mirror bool, url str
                return repo, UpdateRepository(repo)
        }
 
-       // Clone from local repository.
+       // this command could for both migrate and mirror
        _, stderr, err := process.ExecTimeout(10*time.Minute,
+               fmt.Sprintf("MigrateRepository: %s", repoPath),
+               "git", "clone", "--mirror", "--bare", url, repoPath)
+       if err != nil {
+               return repo, errors.New("git clone: " + stderr)
+       }
+       // Clone from local repository.
+       /*_, stderr, err := process.ExecTimeout(10*time.Minute,
                fmt.Sprintf("MigrateRepository(git clone): %s", repoPath),
                "git", "clone", repoPath, tmpDir)
        if err != nil {
@@ -327,7 +334,7 @@ func MigrateRepository(u *User, name, desc string, private, mirror bool, url str
                tmpDir, fmt.Sprintf("MigrateRepository(git push): %s", repoPath),
                "git", "push", "--tags", "origin", "refs/remotes/upstream/*:refs/heads/*"); err != nil {
                return repo, errors.New("git push: " + stderr)
-       }
+       }*/
 
        return repo, UpdateRepository(repo)
 }