diff options
author | 6543 <6543@obermui.de> | 2022-01-20 18:46:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-20 18:46:10 +0100 |
commit | 54e9ee37a7a301dbe74d46fd3c87712e6120e9bf (patch) | |
tree | 1be12fb072625c1b896b9d72f7912b018aad502b /modules/repository | |
parent | 1d98d205f5825f40110e6628b61a97c91ac7f72d (diff) | |
download | gitea-54e9ee37a7a301dbe74d46fd3c87712e6120e9bf.tar.gz gitea-54e9ee37a7a301dbe74d46fd3c87712e6120e9bf.zip |
format with gofumpt (#18184)
* gofumpt -w -l .
* gofumpt -w -l -extra .
* Add linter
* manual fix
* change make fmt
Diffstat (limited to 'modules/repository')
-rw-r--r-- | modules/repository/generate.go | 4 | ||||
-rw-r--r-- | modules/repository/hooks.go | 10 | ||||
-rw-r--r-- | modules/repository/init.go | 6 | ||||
-rw-r--r-- | modules/repository/repo.go | 4 |
4 files changed, 12 insertions, 12 deletions
diff --git a/modules/repository/generate.go b/modules/repository/generate.go index c7ba617919..5b5e1064aa 100644 --- a/modules/repository/generate.go +++ b/modules/repository/generate.go @@ -62,7 +62,7 @@ func generateExpansion(src string, templateRepo, generateRepo *repo_model.Reposi {Name: "TEMPLATE_SSH_URL", Value: templateRepo.CloneLink().SSH, Transformers: nil}, } - var expansionMap = make(map[string]string) + expansionMap := make(map[string]string) for _, e := range expansions { expansionMap[e.Name] = e.Value for _, tr := range e.Transformers { @@ -159,7 +159,7 @@ func generateRepoCommit(ctx context.Context, repo, templateRepo, generateRepo *r if err := os.WriteFile(path, []byte(generateExpansion(string(content), templateRepo, generateRepo)), - 0644); err != nil { + 0o644); err != nil { return err } break diff --git a/modules/repository/hooks.go b/modules/repository/hooks.go index bd77423afc..debaa0ecc4 100644 --- a/modules/repository/hooks.go +++ b/modules/repository/hooks.go @@ -129,7 +129,7 @@ func createDelegateHooks(repoPath string) (err error) { if err = util.Remove(oldHookPath); err != nil && !os.IsNotExist(err) { return fmt.Errorf("unable to pre-remove old hook file '%s' prior to rewriting: %v ", oldHookPath, err) } - if err = os.WriteFile(oldHookPath, []byte(hookTpls[i]), 0777); err != nil { + if err = os.WriteFile(oldHookPath, []byte(hookTpls[i]), 0o777); err != nil { return fmt.Errorf("write old hook file '%s': %v", oldHookPath, err) } @@ -140,7 +140,7 @@ func createDelegateHooks(repoPath string) (err error) { if err = util.Remove(newHookPath); err != nil && !os.IsNotExist(err) { return fmt.Errorf("unable to pre-remove new hook file '%s' prior to rewriting: %v", newHookPath, err) } - if err = os.WriteFile(newHookPath, []byte(giteaHookTpls[i]), 0777); err != nil { + if err = os.WriteFile(newHookPath, []byte(giteaHookTpls[i]), 0o777); err != nil { return fmt.Errorf("write new hook file '%s': %v", newHookPath, err) } @@ -157,7 +157,7 @@ func checkExecutable(filename string) bool { if err != nil { return false } - return (fileInfo.Mode() & 0100) > 0 + return (fileInfo.Mode() & 0o100) > 0 } func ensureExecutable(filename string) error { @@ -165,10 +165,10 @@ func ensureExecutable(filename string) error { if err != nil { return err } - if (fileInfo.Mode() & 0100) > 0 { + if (fileInfo.Mode() & 0o100) > 0 { return nil } - mode := fileInfo.Mode() | 0100 + mode := fileInfo.Mode() | 0o100 return os.Chmod(filename, mode) } diff --git a/modules/repository/init.go b/modules/repository/init.go index c5dd8cb909..d6911161de 100644 --- a/modules/repository/init.go +++ b/modules/repository/init.go @@ -62,7 +62,7 @@ func prepareRepoCommit(ctx context.Context, repo *repo_model.Repository, tmpDir, "OwnerName": repo.OwnerName, } if err = os.WriteFile(filepath.Join(tmpDir, "README.md"), - []byte(com.Expand(string(data), match)), 0644); err != nil { + []byte(com.Expand(string(data), match)), 0o644); err != nil { return fmt.Errorf("write README.md: %v", err) } @@ -81,7 +81,7 @@ func prepareRepoCommit(ctx context.Context, repo *repo_model.Repository, tmpDir, } if buf.Len() > 0 { - if err = os.WriteFile(filepath.Join(tmpDir, ".gitignore"), buf.Bytes(), 0644); err != nil { + if err = os.WriteFile(filepath.Join(tmpDir, ".gitignore"), buf.Bytes(), 0o644); err != nil { return fmt.Errorf("write .gitignore: %v", err) } } @@ -94,7 +94,7 @@ func prepareRepoCommit(ctx context.Context, repo *repo_model.Repository, tmpDir, return fmt.Errorf("GetRepoInitFile[%s]: %v", opts.License, err) } - if err = os.WriteFile(filepath.Join(tmpDir, "LICENSE"), data, 0644); err != nil { + if err = os.WriteFile(filepath.Join(tmpDir, "LICENSE"), data, 0o644); err != nil { return fmt.Errorf("write LICENSE: %v", err) } } diff --git a/modules/repository/repo.go b/modules/repository/repo.go index a8d65a4429..22bdf77093 100644 --- a/modules/repository/repo.go +++ b/modules/repository/repo.go @@ -310,7 +310,7 @@ func PushUpdateAddTag(repo *repo_model.Repository, gitRepo *git.Repository, tagN } var author *user_model.User - var createdAt = time.Unix(1, 0) + createdAt := time.Unix(1, 0) if sig != nil { author, err = user_model.GetUserByEmail(sig.Email) @@ -325,7 +325,7 @@ func PushUpdateAddTag(repo *repo_model.Repository, gitRepo *git.Repository, tagN return fmt.Errorf("CommitsCount: %v", err) } - var rel = models.Release{ + rel := models.Release{ RepoID: repo.ID, TagName: tagName, LowerTagName: strings.ToLower(tagName), |