diff options
author | John Olheiser <john.olheiser@gmail.com> | 2020-08-23 11:02:35 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-23 17:02:35 +0100 |
commit | 43a397ce9ae082e0c6e9367e31743e1cb4d71c20 (patch) | |
tree | 191f7510be4041eaa684bba99480ec0e4bc0bf87 /cmd/doctor.go | |
parent | e7d65cbc6e50d70753f7228c46cbff0cffde7eba (diff) | |
download | gitea-43a397ce9ae082e0c6e9367e31743e1cb4d71c20.tar.gz gitea-43a397ce9ae082e0c6e9367e31743e1cb4d71c20.zip |
Initial support for push options (#12169)
* Initial support for push options
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Fix misspelling 🤦
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Fix formatting after conflict resolution
* defer close git repo
* According the GitLab documentation, git >= 2.10
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Words are hard. Thanks @mrsdizzie :sweat_smile:
Co-authored-by: mrsdizzie <info@mrsdizzie.com>
* Only update if there are push options
Signed-off-by: jolheiser <john.olheiser@gmail.com>
Co-authored-by: mrsdizzie <info@mrsdizzie.com>
Diffstat (limited to 'cmd/doctor.go')
-rw-r--r-- | cmd/doctor.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/cmd/doctor.go b/cmd/doctor.go index 20c1904afa..2a93db27da 100644 --- a/cmd/doctor.go +++ b/cmd/doctor.go @@ -127,6 +127,12 @@ var checklist = []check{ isDefault: false, f: runDoctorUserStarNum, }, + { + title: "Enable push options", + name: "enable-push-options", + isDefault: false, + f: runDoctorEnablePushOptions, + }, // more checks please append here } @@ -605,3 +611,28 @@ func runDoctorCheckDBConsistency(ctx *cli.Context) ([]string, error) { return results, nil } + +func runDoctorEnablePushOptions(ctx *cli.Context) ([]string, error) { + numRepos := 0 + _, err := iterateRepositories(func(repo *models.Repository) ([]string, error) { + numRepos++ + r, err := git.OpenRepository(repo.RepoPath()) + if err != nil { + return nil, err + } + defer r.Close() + + if ctx.Bool("fix") { + _, err := git.NewCommand("config", "receive.advertisePushOptions", "true").RunInDir(r.Path) + return nil, err + } + + return nil, nil + }) + + var prefix string + if !ctx.Bool("fix") { + prefix = "DRY RUN: " + } + return []string{fmt.Sprintf("%sEnabled push options for %d repositories.", prefix, numRepos)}, err +} |