mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08: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:
		@@ -9,6 +9,7 @@ import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/url"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"code.gitea.io/gitea/modules/setting"
 | 
			
		||||
@@ -19,8 +20,28 @@ const (
 | 
			
		||||
	GitAlternativeObjectDirectories = "GIT_ALTERNATE_OBJECT_DIRECTORIES"
 | 
			
		||||
	GitObjectDirectory              = "GIT_OBJECT_DIRECTORY"
 | 
			
		||||
	GitQuarantinePath               = "GIT_QUARANTINE_PATH"
 | 
			
		||||
	GitPushOptionCount              = "GIT_PUSH_OPTION_COUNT"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// GitPushOptions is a wrapper around a map[string]string
 | 
			
		||||
type GitPushOptions map[string]string
 | 
			
		||||
 | 
			
		||||
// GitPushOptions keys
 | 
			
		||||
const (
 | 
			
		||||
	GitPushOptionRepoPrivate  = "repo.private"
 | 
			
		||||
	GitPushOptionRepoTemplate = "repo.template"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Bool checks for a key in the map and parses as a boolean
 | 
			
		||||
func (g GitPushOptions) Bool(key string, def bool) bool {
 | 
			
		||||
	if val, ok := g[key]; ok {
 | 
			
		||||
		if b, err := strconv.ParseBool(val); err == nil {
 | 
			
		||||
			return b
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return def
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// HookOptions represents the options for the Hook calls
 | 
			
		||||
type HookOptions struct {
 | 
			
		||||
	OldCommitIDs                    []string
 | 
			
		||||
@@ -31,6 +52,7 @@ type HookOptions struct {
 | 
			
		||||
	GitObjectDirectory              string
 | 
			
		||||
	GitAlternativeObjectDirectories string
 | 
			
		||||
	GitQuarantinePath               string
 | 
			
		||||
	GitPushOptions                  GitPushOptions
 | 
			
		||||
	ProtectedBranchID               int64
 | 
			
		||||
	IsDeployKey                     bool
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user