mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	Fix #174
This commit is contained in:
		@@ -9,8 +9,6 @@ RUN_MODE = dev
 | 
				
			|||||||
[repository]
 | 
					[repository]
 | 
				
			||||||
ROOT = 
 | 
					ROOT = 
 | 
				
			||||||
SCRIPT_TYPE = bash
 | 
					SCRIPT_TYPE = bash
 | 
				
			||||||
LANG_IGNS = Google Go|C|C++|Python|Ruby|C Sharp|Java|Objective-C|Android
 | 
					 | 
				
			||||||
LICENSES = Apache v2 License|GPL v2|MIT License|Affero GPL|Artistic License 2.0|BSD (3-Clause) License
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
[server]
 | 
					[server]
 | 
				
			||||||
PROTOCOL = http
 | 
					PROTOCOL = http
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,6 +18,7 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	"github.com/Unknwon/cae/zip"
 | 
						"github.com/Unknwon/cae/zip"
 | 
				
			||||||
	"github.com/Unknwon/com"
 | 
						"github.com/Unknwon/com"
 | 
				
			||||||
 | 
						qlog "github.com/qiniu/log"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/gogits/git"
 | 
						"github.com/gogits/git"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -39,8 +40,38 @@ var (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func LoadRepoConfig() {
 | 
					func LoadRepoConfig() {
 | 
				
			||||||
	LanguageIgns = strings.Split(base.Cfg.MustValue("repository", "LANG_IGNS"), "|")
 | 
						workDir, err := base.ExecDir()
 | 
				
			||||||
	Licenses = strings.Split(base.Cfg.MustValue("repository", "LICENSES"), "|")
 | 
						if err != nil {
 | 
				
			||||||
 | 
							qlog.Fatalf("Fail to get work directory: %s\n", err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Load .gitignore and license files.
 | 
				
			||||||
 | 
						types := []string{"gitignore", "license"}
 | 
				
			||||||
 | 
						typeFiles := make([][]string, 2)
 | 
				
			||||||
 | 
						for i, t := range types {
 | 
				
			||||||
 | 
							cfgPath := filepath.Join(workDir, "conf", t)
 | 
				
			||||||
 | 
							files, err := com.StatDir(cfgPath)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								qlog.Fatalf("Fail to get default %s files: %v\n", t, err)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							cfgPath = filepath.Join(workDir, "custom/conf/gitignore")
 | 
				
			||||||
 | 
							if com.IsDir(cfgPath) {
 | 
				
			||||||
 | 
								customFiles, err := com.StatDir(cfgPath)
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									qlog.Fatalf("Fail to get custom %s files: %v\n", t, err)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								for _, f := range customFiles {
 | 
				
			||||||
 | 
									if !com.IsSliceContainsStr(files, f) {
 | 
				
			||||||
 | 
										files = append(files, f)
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							typeFiles[i] = files
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						LanguageIgns = typeFiles[0]
 | 
				
			||||||
 | 
						Licenses = typeFiles[1]
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func NewRepoContext() {
 | 
					func NewRepoContext() {
 | 
				
			||||||
@@ -49,15 +80,12 @@ func NewRepoContext() {
 | 
				
			|||||||
	// Check if server has basic git setting.
 | 
						// Check if server has basic git setting.
 | 
				
			||||||
	stdout, stderr, err := com.ExecCmd("git", "config", "--get", "user.name")
 | 
						stdout, stderr, err := com.ExecCmd("git", "config", "--get", "user.name")
 | 
				
			||||||
	if strings.Contains(stderr, "fatal:") {
 | 
						if strings.Contains(stderr, "fatal:") {
 | 
				
			||||||
		fmt.Printf("repo.NewRepoContext(fail to get git user.name): %s", stderr)
 | 
							qlog.Fatalf("repo.NewRepoContext(fail to get git user.name): %s", stderr)
 | 
				
			||||||
		os.Exit(2)
 | 
					 | 
				
			||||||
	} else if err != nil || len(strings.TrimSpace(stdout)) == 0 {
 | 
						} else if err != nil || len(strings.TrimSpace(stdout)) == 0 {
 | 
				
			||||||
		if _, stderr, err = com.ExecCmd("git", "config", "--global", "user.email", "gogitservice@gmail.com"); err != nil {
 | 
							if _, stderr, err = com.ExecCmd("git", "config", "--global", "user.email", "gogitservice@gmail.com"); err != nil {
 | 
				
			||||||
			fmt.Printf("repo.NewRepoContext(fail to set git user.email): %s", stderr)
 | 
								qlog.Fatalf("repo.NewRepoContext(fail to set git user.email): %s", stderr)
 | 
				
			||||||
			os.Exit(2)
 | 
					 | 
				
			||||||
		} else if _, stderr, err = com.ExecCmd("git", "config", "--global", "user.name", "Gogs"); err != nil {
 | 
							} else if _, stderr, err = com.ExecCmd("git", "config", "--global", "user.name", "Gogs"); err != nil {
 | 
				
			||||||
			fmt.Printf("repo.NewRepoContext(fail to set git user.name): %s", stderr)
 | 
								qlog.Fatalf("repo.NewRepoContext(fail to set git user.name): %s", stderr)
 | 
				
			||||||
			os.Exit(2)
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user