Browse Source

bug fixed for migrate and fixed #141

tags/v0.9.99
lunnyxiao 9 years ago
parent
commit
1240fef0ca
1 changed files with 10 additions and 3 deletions
  1. 10
    3
      models/repo.go

+ 10
- 3
models/repo.go View File



// MigrateRepository migrates a existing repository from other project hosting. // MigrateRepository migrates a existing repository from other project hosting.
func MigrateRepository(u *User, name, desc string, private, mirror bool, url string) (*Repository, error) { 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 { if err != nil {
return nil, err return nil, err
} }
return repo, UpdateRepository(repo) return repo, UpdateRepository(repo)
} }


// Clone from local repository.
// this command could for both migrate and mirror
_, stderr, err := process.ExecTimeout(10*time.Minute, _, 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), fmt.Sprintf("MigrateRepository(git clone): %s", repoPath),
"git", "clone", repoPath, tmpDir) "git", "clone", repoPath, tmpDir)
if err != nil { if err != nil {
tmpDir, fmt.Sprintf("MigrateRepository(git push): %s", repoPath), tmpDir, fmt.Sprintf("MigrateRepository(git push): %s", repoPath),
"git", "push", "--tags", "origin", "refs/remotes/upstream/*:refs/heads/*"); err != nil { "git", "push", "--tags", "origin", "refs/remotes/upstream/*:refs/heads/*"); err != nil {
return repo, errors.New("git push: " + stderr) return repo, errors.New("git push: " + stderr)
}
}*/


return repo, UpdateRepository(repo) return repo, UpdateRepository(repo)
} }

Loading…
Cancel
Save