diff options
author | 6543 | 2022-01-20 18:46:10 +0100 |
---|---|---|
committer | GitHub | 2022-01-20 18:46:10 +0100 |
commit | 54e9ee37a7a301dbe74d46fd3c87712e6120e9bf (patch) | |
tree | 1be12fb072625c1b896b9d72f7912b018aad502b /contrib | |
parent | 1d98d205f5825f40110e6628b61a97c91ac7f72d (diff) |
format with gofumpt (#18184)
* gofumpt -w -l .
* gofumpt -w -l -extra .
* Add linter
* manual fix
* change make fmt
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/fixtures/fixture_generation.go | 2 | ||||
-rw-r--r-- | contrib/pr/checkout.go | 35 |
2 files changed, 19 insertions, 18 deletions
diff --git a/contrib/fixtures/fixture_generation.go b/contrib/fixtures/fixture_generation.go index 74996a1f3..66ff5c54e 100644 --- a/contrib/fixtures/fixture_generation.go +++ b/contrib/fixtures/fixture_generation.go @@ -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) diff --git a/contrib/pr/checkout.go b/contrib/pr/checkout.go index e9dd675d4..ceeba4de3 100644 --- a/contrib/pr/checkout.go +++ b/contrib/pr/checkout.go @@ -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:]...) |