From 6e5fffbd3f5414ead3f617f6f07c597ee6cfdf06 Mon Sep 17 00:00:00 2001
From: Lunny Xiao <xiaolunwen@gmail.com>
Date: Sat, 31 Dec 2016 17:34:34 +0800
Subject: [PATCH] resolved #485: when migrate empty wiki repo, then ignore
 (#541)

---
 models/repo.go | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/models/repo.go b/models/repo.go
index ce9740f8c..b4f493580 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -691,7 +691,6 @@ func MigrateRepository(u *User, opts MigrateRepoOptions) (*Repository, error) {
 
 	wikiRemotePath := wikiRemoteURL(opts.RemoteAddr)
 	if len(wikiRemotePath) > 0 {
-
 		if err := os.RemoveAll(wikiPath); err != nil {
 			return repo, fmt.Errorf("Fail to remove %s: %v", wikiPath, err)
 		}
@@ -700,8 +699,12 @@ func MigrateRepository(u *User, opts MigrateRepoOptions) (*Repository, error) {
 			Mirror:  true,
 			Quiet:   true,
 			Timeout: migrateTimeout,
+			Branch:  "master",
 		}); err != nil {
-			log.Info("Clone wiki: %v", err)
+			log.Warn("Clone wiki: %v", err)
+			if err := os.RemoveAll(wikiPath); err != nil {
+				return repo, fmt.Errorf("Fail to remove %s: %v", wikiPath, err)
+			}
 		}
 	}