mirror of
https://github.com/go-gitea/gitea
synced 2025-07-23 02:38:35 +00:00
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 😅 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>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user