format with gofumpt (#18184)

* gofumpt -w -l .

* gofumpt -w -l -extra .

* Add linter

* manual fix

* change make fmt
This commit is contained in:
6543 2022-01-20 18:46:10 +01:00 committed by GitHub
parent 1d98d205f5
commit 54e9ee37a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
423 changed files with 1585 additions and 1758 deletions

View file

@ -66,7 +66,7 @@ func generate(name string) error {
return err
}
path := filepath.Join(fixturesDir, name+".yml")
if err := os.WriteFile(path, []byte(data), 0644); err != nil {
if err := os.WriteFile(path, []byte(data), 0o644); err != nil {
return fmt.Errorf("%s: %+v", path, err)
}
fmt.Printf("%s created.\n", path)

View file

@ -93,13 +93,13 @@ func runPR() {
routers.InitGitServices()
setting.Database.LogSQL = true
//x, err = xorm.NewEngine("sqlite3", "file::memory:?cache=shared")
// x, err = xorm.NewEngine("sqlite3", "file::memory:?cache=shared")
db.InitEngineWithMigration(context.Background(), func(_ *xorm.Engine) error {
return nil
})
db.HasEngine = true
//x.ShowSQL(true)
// x.ShowSQL(true)
err = unittest.InitFixtures(
unittest.FixturesOptions{
Dir: path.Join(curDir, "models/fixtures/"),
@ -115,7 +115,7 @@ func runPR() {
util.CopyDir(path.Join(curDir, "integrations/gitea-repositories-meta"), setting.RepoRootPath)
log.Printf("[PR] Setting up router\n")
//routers.GlobalInit()
// routers.GlobalInit()
external.RegisterRenderers()
markup.Init()
c := routers.NormalRoutes()
@ -137,7 +137,7 @@ func runPR() {
}
*/
//Start the server
// Start the server
http.ListenAndServe(":8080", c)
log.Printf("[PR] Cleaning up ...\n")
@ -160,7 +160,7 @@ func runPR() {
}
func main() {
var runPRFlag = flag.Bool("run", false, "Run the PR code")
runPRFlag := flag.Bool("run", false, "Run the PR code")
flag.Parse()
if *runPRFlag {
runPR()
@ -173,15 +173,15 @@ func main() {
force = false
}
//Otherwise checkout PR
// Otherwise checkout PR
if len(os.Args) != 2 {
log.Fatal("Need only one arg: the PR number")
}
pr := os.Args[1]
codeFilePath = filepath.FromSlash(codeFilePath) //Convert to running OS
codeFilePath = filepath.FromSlash(codeFilePath) // Convert to running OS
//Copy this file if it will not exist in the PR branch
// Copy this file if it will not exist in the PR branch
dat, err := os.ReadFile(codeFilePath)
if err != nil {
log.Fatalf("Failed to cache this code file : %v", err)
@ -192,16 +192,16 @@ func main() {
log.Fatalf("Failed to open the repo : %v", err)
}
//Find remote upstream
// Find remote upstream
remotes, err := repo.Remotes()
if err != nil {
log.Fatalf("Failed to list remotes of repo : %v", err)
}
remoteUpstream := "origin" //Default
remoteUpstream := "origin" // Default
for _, r := range remotes {
if r.Config().URLs[0] == "https://github.com/go-gitea/gitea.git" ||
r.Config().URLs[0] == "https://github.com/go-gitea/gitea" ||
r.Config().URLs[0] == "git@github.com:go-gitea/gitea.git" { //fetch at index 0
r.Config().URLs[0] == "git@github.com:go-gitea/gitea.git" { // fetch at index 0
remoteUpstream = r.Config().Name
break
}
@ -212,7 +212,7 @@ func main() {
log.Printf("Fetching PR #%s in %s\n", pr, branch)
if runtime.GOOS == "windows" {
//Use git cli command for windows
// Use git cli command for windows
runCmd("git", "fetch", remoteUpstream, fmt.Sprintf("pull/%s/head:%s", pr, branch))
} else {
ref := fmt.Sprintf("%s%s/head:%s", gitea_git.PullPrefix, pr, branchRef)
@ -240,22 +240,23 @@ func main() {
log.Fatalf("Failed to checkout %s : %v", branch, err)
}
//Copy this file if not exist
// Copy this file if not exist
if _, err := os.Stat(codeFilePath); os.IsNotExist(err) {
err = os.MkdirAll(filepath.Dir(codeFilePath), 0755)
err = os.MkdirAll(filepath.Dir(codeFilePath), 0o755)
if err != nil {
log.Fatalf("Failed to duplicate this code file in PR : %v", err)
}
err = os.WriteFile(codeFilePath, dat, 0644)
err = os.WriteFile(codeFilePath, dat, 0o644)
if err != nil {
log.Fatalf("Failed to duplicate this code file in PR : %v", err)
}
}
//Force build of js, css, bin, ...
// Force build of js, css, bin, ...
runCmd("make", "build")
//Start with integration test
// Start with integration test
runCmd("go", "run", "-mod", "vendor", "-tags", "sqlite sqlite_unlock_notify", codeFilePath, "-run")
}
func runCmd(cmd ...string) {
log.Printf("Executing : %s ...\n", cmd)
c := exec.Command(cmd[0], cmd[1:]...)