File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,10 @@ func (c *blankContext) AuthToken() (string, error) {
2626 return c .authToken , nil
2727}
2828
29+ func (c * blankContext ) SetAuthToken (t string ) {
30+ c .authToken = t
31+ }
32+
2933func (c * blankContext ) AuthLogin () (string , error ) {
3034 return c .authLogin , nil
3135}
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import (
1010// Context represents the interface for querying information about the current environment
1111type Context interface {
1212 AuthToken () (string , error )
13+ SetAuthToken (string )
1314 AuthLogin () (string , error )
1415 Branch () (string , error )
1516 SetBranch (string )
@@ -36,10 +37,11 @@ func InitDefaultContext() Context {
3637
3738// A Context implementation that queries the filesystem
3839type fsContext struct {
39- config * configEntry
40- remotes Remotes
41- branch string
42- baseRepo * GitHubRepository
40+ config * configEntry
41+ remotes Remotes
42+ branch string
43+ baseRepo * GitHubRepository
44+ authToken string
4345}
4446
4547func (c * fsContext ) configFile () string {
@@ -54,18 +56,27 @@ func (c *fsContext) getConfig() (*configEntry, error) {
5456 return nil , err
5557 }
5658 c .config = entry
59+ c .authToken = ""
5760 }
5861 return c .config , nil
5962}
6063
6164func (c * fsContext ) AuthToken () (string , error ) {
65+ if c .authToken != "" {
66+ return c .authToken , nil
67+ }
68+
6269 config , err := c .getConfig ()
6370 if err != nil {
6471 return "" , err
6572 }
6673 return config .Token , nil
6774}
6875
76+ func (c * fsContext ) SetAuthToken (t string ) {
77+ c .authToken = t
78+ }
79+
6980func (c * fsContext ) AuthLogin () (string , error ) {
7081 config , err := c .getConfig ()
7182 if err != nil {
You can’t perform that action at this time.
0 commit comments