@@ -22,15 +22,32 @@ export const cloneRepository = async (
2222 progress : onProgress ,
2323 } ) . cwd ( {
2424 path,
25- } )
26-
27- await git . clone (
28- cloneUrl ,
29- path ,
30- [
31- "--bare" ,
32- ]
33- ) ;
25+ } ) ;
26+
27+ const isAzureDevOps = remoteUrl . hostname . includes ( 'devops' ) ;
28+
29+ if ( isAzureDevOps && remoteUrl . password ) {
30+ const token = remoteUrl . password ;
31+ const authHeader = `Authorization: Basic ${ Buffer . from ( `:${ token } ` ) . toString ( 'base64' ) } ` ;
32+
33+ await git . clone (
34+ remoteUrl . origin + remoteUrl . pathname ,
35+ path ,
36+ [
37+ "--bare" ,
38+ "-c" ,
39+ `http.extraHeader=${ authHeader } `
40+ ]
41+ ) ;
42+ } else {
43+ await git . clone (
44+ remoteUrl . toString ( ) ,
45+ path ,
46+ [
47+ "--bare" ,
48+ ]
49+ ) ;
50+ }
3451
3552 await unsetGitConfig ( path , [ "remote.origin.url" ] ) ;
3653 } catch ( error : unknown ) {
@@ -63,14 +80,31 @@ export const fetchRepository = async (
6380 progress : onProgress ,
6481 } ) . cwd ( {
6582 path : path ,
66- } )
67-
68- await git . fetch ( [
69- cloneUrl ,
70- "+refs/heads/*:refs/heads/*" ,
71- "--prune" ,
72- "--progress"
73- ] ) ;
83+ } ) ;
84+
85+ const isAzureDevOps = remoteUrl . hostname . includes ( 'devops' ) ;
86+
87+ if ( isAzureDevOps && remoteUrl . password ) {
88+ const token = remoteUrl . password ;
89+ const authHeader = `Authorization: Basic ${ Buffer . from ( `:${ token } ` ) . toString ( 'base64' ) } ` ;
90+
91+ // Temporarily set git configuration
92+ await git . addConfig ( 'http.extraHeader' , authHeader ) ;
93+
94+ await git . fetch ( [
95+ remoteUrl . origin + remoteUrl . pathname ,
96+ "+refs/heads/*:refs/heads/*" ,
97+ "--prune" ,
98+ "--progress"
99+ ] ) ;
100+ } else {
101+ await git . fetch ( [
102+ remoteUrl . toString ( ) ,
103+ "+refs/heads/*:refs/heads/*" ,
104+ "--prune" ,
105+ "--progress"
106+ ] ) ;
107+ }
74108 } catch ( error : unknown ) {
75109 const baseLog = `Failed to fetch repository: ${ path } ` ;
76110 if ( env . SOURCEBOT_LOG_LEVEL !== "debug" ) {
0 commit comments