@@ -33,6 +33,8 @@ func ConfigGetURLMatch(key, url string) string {
3333 return strings .TrimSpace (string (stdout .Bytes ()))
3434}
3535
36+ // SetGlobalConfig allows to set system-wide Git configuration.
37+ // The application exits in case of error.
3638func SetGlobalConfig (url , section , key , value string ) {
3739 x := fmt .Sprintf ("%s.%s.%s" , section , url , key )
3840 args := []string {"config" , "--global" , x , value }
@@ -43,6 +45,8 @@ func SetGlobalConfig(url, section, key, value string) {
4345 }
4446}
4547
48+ // PassThruRemoteHTTPSHelper exec the git-remote-https helper,
49+ // which allows the caller to transparently pass-thru it.
4650func PassThruRemoteHTTPSHelper (remote , url string ) {
4751 u , err := _url .Parse (url )
4852 if err != nil {
@@ -63,6 +67,8 @@ func PassThruRemoteHTTPSHelper(remote, url string) {
6367 }
6468}
6569
70+ // StoreCredentials persists credentials on disk, using the built-in
71+ // git-credential-store helper.
6672func StoreCredentials (protocol , host , username , password string ) error {
6773 var stdin bytes.Buffer
6874
@@ -80,6 +86,7 @@ func StoreCredentials(protocol, host, username, password string) error {
8086 return res
8187}
8288
89+ // GetCredentials retrieves credentials from the built-in git-credential-store helper.
8390func GetCredentials (protocol , host , username string ) (string , error ) {
8491 var stdin , stdout bytes.Buffer
8592
@@ -102,6 +109,7 @@ func GetCredentials(protocol, host, username string) (string, error) {
102109 return "" , fmt .Errorf ("GetCredentials - not found for protocol=%s,host=%s,username=%s" , protocol , host , username )
103110}
104111
112+ // InstallProtocol configure Git to allow a given protocol on the system.
105113func InstallProtocol (protocol string ) {
106114 protocol = fmt .Sprintf ("protocol.%s.allow" , protocol )
107115 args := []string {"config" , "--global" , protocol , "always" }
0 commit comments