@@ -112,6 +112,20 @@ async fn upload_release_artifact(
112
112
Ok ( ( ) )
113
113
}
114
114
115
+ fn new_github_client ( args : & ArgMatches ) -> Result < ( Octocrab , String ) > {
116
+ let token = args
117
+ . get_one :: < String > ( "token" )
118
+ . expect ( "token should be specified" )
119
+ . to_string ( ) ;
120
+ let github_uri = args. get_one :: < String > ( "github-uri" ) ;
121
+
122
+ let mut builder = OctocrabBuilder :: new ( ) . personal_token ( token. clone ( ) ) ;
123
+ if let Some ( github_uri) = github_uri {
124
+ builder = builder. base_uri ( github_uri. clone ( ) ) ?;
125
+ }
126
+ Ok ( ( builder. build ( ) ?, token) )
127
+ }
128
+
115
129
pub async fn command_fetch_release_distributions ( args : & ArgMatches ) -> Result < ( ) > {
116
130
let dest_dir = args
117
131
. get_one :: < PathBuf > ( "dest" )
@@ -121,13 +135,7 @@ pub async fn command_fetch_release_distributions(args: &ArgMatches) -> Result<()
121
135
. expect ( "organization should be set" ) ;
122
136
let repo = args. get_one :: < String > ( "repo" ) . expect ( "repo should be set" ) ;
123
137
124
- let client = OctocrabBuilder :: new ( )
125
- . personal_token (
126
- args. get_one :: < String > ( "token" )
127
- . expect ( "token should be required argument" )
128
- . to_string ( ) ,
129
- )
130
- . build ( ) ?;
138
+ let ( client, _) = new_github_client ( args) ?;
131
139
132
140
let release_version_range = pep440_rs:: VersionSpecifier :: from_str ( ">=3.9" ) ?;
133
141
@@ -358,10 +366,6 @@ pub async fn command_upload_release_distributions(args: &ArgMatches) -> Result<(
358
366
. get_one :: < String > ( "tag" )
359
367
. expect ( "tag should be specified" ) ;
360
368
let ignore_missing = args. get_flag ( "ignore_missing" ) ;
361
- let token = args
362
- . get_one :: < String > ( "token" )
363
- . expect ( "token should be specified" )
364
- . to_string ( ) ;
365
369
let organization = args
366
370
. get_one :: < String > ( "organization" )
367
371
. expect ( "organization should be specified" ) ;
@@ -451,9 +455,7 @@ pub async fn command_upload_release_distributions(args: &ArgMatches) -> Result<(
451
455
return Err ( anyhow ! ( "missing {} release artifacts" , missing. len( ) ) ) ;
452
456
}
453
457
454
- let client = OctocrabBuilder :: new ( )
455
- . personal_token ( token. clone ( ) )
456
- . build ( ) ?;
458
+ let ( client, token) = new_github_client ( args) ?;
457
459
let repo_handler = client. repos ( organization, repo) ;
458
460
let releases = repo_handler. releases ( ) ;
459
461
0 commit comments