@@ -30,8 +30,8 @@ func (c *envConfig) Hosts() ([]string, error) {
3030 hasDefault = true
3131 }
3232 }
33- _ , _ , found := AuthTokenFromEnv (ghinstance .Default ())
34- if (err != nil || ! hasDefault ) && found {
33+ token , _ := AuthTokenFromEnv (ghinstance .Default ())
34+ if (err != nil || ! hasDefault ) && token != "" {
3535 hosts = append ([]string {ghinstance .Default ()}, hosts ... )
3636 return hosts , nil
3737 }
@@ -45,7 +45,7 @@ func (c *envConfig) Get(hostname, key string) (string, error) {
4545
4646func (c * envConfig ) GetWithSource (hostname , key string ) (string , string , error ) {
4747 if hostname != "" && key == "oauth_token" {
48- if token , env , found := AuthTokenFromEnv (hostname ); found {
48+ if token , env := AuthTokenFromEnv (hostname ); token != "" {
4949 return token , env , nil
5050 }
5151 }
@@ -55,28 +55,26 @@ func (c *envConfig) GetWithSource(hostname, key string) (string, string, error)
5555
5656func (c * envConfig ) CheckWriteable (hostname , key string ) error {
5757 if hostname != "" && key == "oauth_token" {
58- if _ , env , found := AuthTokenFromEnv (hostname ); found {
58+ if token , env := AuthTokenFromEnv (hostname ); token != "" {
5959 return fmt .Errorf ("read-only token in %s cannot be modified" , env )
6060 }
6161 }
6262
6363 return c .Config .CheckWriteable (hostname , key )
6464}
6565
66- func AuthTokenFromEnv (hostname string ) (string , string , bool ) {
66+ func AuthTokenFromEnv (hostname string ) (string , string ) {
6767 if ghinstance .IsEnterprise (hostname ) {
68- if token , found := os .LookupEnv (GH_ENTERPRISE_TOKEN ); found {
69- return token , GH_ENTERPRISE_TOKEN , found
68+ if token := os .Getenv (GH_ENTERPRISE_TOKEN ); token != "" {
69+ return token , GH_ENTERPRISE_TOKEN
7070 }
7171
72- token , found := os .LookupEnv (GITHUB_ENTERPRISE_TOKEN )
73- return token , GITHUB_ENTERPRISE_TOKEN , found
72+ return os .Getenv (GITHUB_ENTERPRISE_TOKEN ), GITHUB_ENTERPRISE_TOKEN
7473 }
7574
76- if token , found := os .LookupEnv (GH_TOKEN ); found {
77- return token , GH_TOKEN , found
75+ if token := os .Getenv (GH_TOKEN ); token != "" {
76+ return token , GH_TOKEN
7877 }
7978
80- token , found := os .LookupEnv (GITHUB_TOKEN )
81- return token , GITHUB_TOKEN , found
79+ return os .Getenv (GITHUB_TOKEN ), GITHUB_TOKEN
8280}
0 commit comments