@@ -67,40 +67,25 @@ public static GitHubBuilder fromCredentials() throws IOException {
6767 else
6868 throw new IOException ("Failed to resolve credentials from ~/.github or the environment." , e );
6969 }
70-
7170 }
7271
7372 public static GitHubBuilder fromEnvironment (String loginVariableName , String passwordVariableName , String oauthVariableName ) throws IOException {
7473 return fromEnvironment (loginVariableName , passwordVariableName , oauthVariableName , "" );
7574 }
76-
77- public static GitHubBuilder fromEnvironment (String loginVariableName , String passwordVariableName , String oauthVariableName , String endpointVariableName ) throws IOException {
78-
79-
80- Properties env = new Properties ();
81-
82- Object loginValue = System .getenv (loginVariableName );
83-
84- if (loginValue != null )
85- env .put ("login" , loginValue );
86-
87- Object passwordValue = System .getenv (passwordVariableName );
88-
89- if (passwordValue != null )
90- env .put ("password" , passwordValue );
91-
92- Object oauthValue = System .getenv (oauthVariableName );
93-
94- if (oauthValue != null )
95- env .put ("oauth" , oauthValue );
96-
97- Object endPoint = System .getenv (endpointVariableName );
9875
99- if (endPoint != null )
100- env .put ("endpoint" , endPoint );
76+ private static void loadIfSet (String envName , Properties p , String propName ) {
77+ String v = System .getenv (envName );
78+ if (v != null )
79+ p .put (propName , v );
80+ }
10181
82+ public static GitHubBuilder fromEnvironment (String loginVariableName , String passwordVariableName , String oauthVariableName , String endpointVariableName ) throws IOException {
83+ Properties env = new Properties ();
84+ loadIfSet (loginVariableName ,env ,"login" );
85+ loadIfSet (passwordVariableName ,env ,"password" );
86+ loadIfSet (oauthVariableName ,env ,"oauth" );
87+ loadIfSet (endpointVariableName ,env ,"endpoint" );
10288 return fromProperties (env );
103-
10489 }
10590
10691 public static GitHubBuilder fromEnvironment () throws IOException {
0 commit comments