github.com/drone/runner-go@v1.12.0/clone/environ.go (about)

     1  // Copyright 2019 Drone.IO Inc. All rights reserved.
     2  // Use of this source code is governed by the Polyform License
     3  // that can be found in the LICENSE file.
     4  
     5  package clone
     6  
     7  // Config provides the Git Configuration parameters.
     8  type Config struct {
     9  	User       User
    10  	Trace      bool
    11  	SkipVerify bool
    12  }
    13  
    14  // User provides the Git user parameters.
    15  type User struct {
    16  	Name  string
    17  	Email string
    18  }
    19  
    20  // Environ returns a set of global Git environment variables,
    21  // from the configuration input.
    22  func Environ(config Config) map[string]string {
    23  	environ := map[string]string{
    24  		"GIT_AUTHOR_NAME":     "drone",
    25  		"GIT_AUTHOR_EMAIL":    "noreply@drone",
    26  		"GIT_COMMITTER_NAME":  "drone",
    27  		"GIT_COMMITTER_EMAIL": "noreply@drone",
    28  		"GIT_TERMINAL_PROMPT": "0",
    29  	}
    30  	if s := config.User.Name; s != "" {
    31  		environ["GIT_AUTHOR_NAME"] = s
    32  		environ["GIT_COMMITTER_NAME"] = s
    33  	}
    34  	if s := config.User.Email; s != "" {
    35  		environ["GIT_AUTHOR_EMAIL"] = s
    36  		environ["GIT_COMMITTER_EMAIL"] = s
    37  	}
    38  	if config.Trace {
    39  		environ["GIT_TRACE"] = "true"
    40  	}
    41  	if config.SkipVerify {
    42  		environ["GIT_SSL_NO_VERIFY"] = "true"
    43  	}
    44  	return environ
    45  }