@@ -20,6 +20,7 @@ import git from 'isomorphic-git';
20
20
import http from 'isomorphic-git/http/web' ;
21
21
import { determine_fetch_remote , find_repo_root } from '../git-helpers.js' ;
22
22
import { SHOW_USAGE } from '../help.js' ;
23
+ import { authentication_options , Authenticator } from '../auth.js' ;
23
24
24
25
export default {
25
26
name : 'fetch' ,
@@ -35,7 +36,8 @@ export default {
35
36
description : 'Fetch all remotes.' ,
36
37
type : 'boolean' ,
37
38
default : false ,
38
- }
39
+ } ,
40
+ ...authentication_options ,
39
41
} ,
40
42
} ,
41
43
execute : async ( ctx ) => {
@@ -54,6 +56,15 @@ export default {
54
56
gitdir,
55
57
} ) ;
56
58
59
+ if ( ! options . username !== ! options . password ) {
60
+ stderr ( 'Please specify both --username and --password, or neither' ) ;
61
+ return 1 ;
62
+ }
63
+ const authenticator = new Authenticator ( {
64
+ username : options . username ,
65
+ password : options . password ,
66
+ } ) ;
67
+
57
68
if ( options . all ) {
58
69
for ( const { remote, url } of remotes ) {
59
70
stdout ( `Fetching ${ remote } \nFrom ${ url } ` ) ;
@@ -66,6 +77,7 @@ export default {
66
77
gitdir,
67
78
remote,
68
79
onMessage : ( message ) => { stdout ( message ) ; } ,
80
+ ...authenticator . get_auth_callbacks ( stderr ) ,
69
81
} ) ;
70
82
}
71
83
return ;
@@ -83,6 +95,7 @@ export default {
83
95
gitdir,
84
96
...remote_data ,
85
97
onMessage : ( message ) => { stdout ( message ) ; } ,
98
+ ...authenticator . get_auth_callbacks ( stderr ) ,
86
99
} ) ;
87
100
}
88
101
}
0 commit comments