summaryrefslogtreecommitdiffstats
path: root/models/repo.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-07-26 19:22:17 +0800
committerUnknwon <u@gogs.io>2015-07-26 19:22:17 +0800
commit6f8e388b5530e85f141ea3aa345b1c6842fbe1f5 (patch)
tree3ea3119fa2a1292c801aaddddc00308c434bf6ca /models/repo.go
parent436ef5b50a32c7ff2053bce7f5b3eaf6abe0c984 (diff)
downloadgitea-6f8e388b5530e85f141ea3aa345b1c6842fbe1f5.tar.gz
gitea-6f8e388b5530e85f141ea3aa345b1c6842fbe1f5.zip
fix #1169
- prevent create reop on existed path
Diffstat (limited to 'models/repo.go')
-rw-r--r--models/repo.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/models/repo.go b/models/repo.go
index 35f63e12a8..f339f1737a 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -423,13 +423,18 @@ func createUpdateHook(repoPath string) error {
// InitRepository initializes README and .gitignore if needed.
func initRepository(e Engine, repoPath string, u *User, repo *Repository, initReadme bool, repoLang, license string) error {
+ // Somehow the directory could exist.
+ if com.IsExist(repoPath) {
+ return fmt.Errorf("initRepository: path already exists: %s", repoPath)
+ }
+
// Init bare new repository.
os.MkdirAll(repoPath, os.ModePerm)
_, stderr, err := process.ExecDir(-1, repoPath,
fmt.Sprintf("initRepository(git init --bare): %s", repoPath),
"git", "init", "--bare")
if err != nil {
- return errors.New("git init --bare: " + stderr)
+ return fmt.Errorf("git init --bare: %s", err)
}
if err := createUpdateHook(repoPath); err != nil {