@@ -7,7 +7,7 @@ class Main {
7
7
{
8
8
var parts = s .split (" " );
9
9
if (parts [0 ] != " Basic" )
10
- throw " HTTP authentication schemes other than Basic not supported" ;
10
+ throw " ERR: HTTP authentication schemes other than Basic not supported" ;
11
11
return haxe.crypto. Base64 .decode (parts [1 ]);
12
12
}
13
13
@@ -29,14 +29,16 @@ class Main {
29
29
ChildProcess .exec (' git clone --quiet --mirror " $remote " " $local "' , callback );
30
30
}
31
31
32
- static function fetch (local , callback )
32
+ static function fetch (remote , local , callback )
33
33
{
34
- ChildProcess .exec (' git -C " $local " fetch --quiet' , callback );
34
+ ChildProcess .exec (' git -C " $local " remote set-url origin " $remote "' , function (err , stdout , stderr ) {
35
+ ChildProcess .exec (' git -C " $local " fetch --quiet' , callback );
36
+ });
35
37
}
36
38
37
39
static function authenticate (params , callback )
38
40
{
39
- trace (" authenticating on the upstream repo" );
41
+ trace (' INFO: authenticating on the upstream repo ${ params . repo } ' );
40
42
var req = Https .request (' https:// ${params .repo }/info/refs?service= ${params .service }' , callback );
41
43
req .setHeader (" User-Agent" , " git/" );
42
44
if (params .auth != null )
@@ -48,20 +50,25 @@ class Main {
48
50
{
49
51
if (! updatePromises .exists (local )) {
50
52
updatePromises [local ] = new Promise (function (resolve , reject ) {
51
- trace (" updating: fetching" );
52
- fetch (local , function (ferr , stdout , stderr ) {
53
+ trace (' INFO: updating: fetching from $ remote ' );
54
+ fetch (remote , local , function (ferr , stdout , stderr ) {
53
55
if (ferr != null ) {
54
- trace (" updating: fetch failed, cloning" );
56
+ trace (" WARN: updating: fetch failed" );
57
+ trace (stdout );
58
+ trace (stderr );
59
+ trace (" WARN: continuing with clone" );
55
60
clone (remote , local , function (cerr , stdout , stderr ) {
56
61
if (cerr != null ) {
57
- resolve (' git clone exited with non-zero status: ${cerr .code }' );
62
+ trace (stdout );
63
+ trace (stderr );
64
+ resolve (' ERR: git clone exited with non-zero status: ${cerr .code }' );
58
65
} else {
59
- trace (" updating: success" );
66
+ trace (" INFO: updating via clone : success" );
60
67
resolve (null );
61
68
}
62
69
});
63
70
} else {
64
- trace (" updating: success" );
71
+ trace (" INFO: updating via fetch : success" );
65
72
resolve (null );
66
73
}
67
74
});
@@ -75,11 +82,11 @@ class Main {
75
82
return Promise .reject (err );
76
83
});
77
84
} else {
78
- trace (" reusing existing promise" );
85
+ trace (" INFO: reusing existing promise" );
79
86
}
80
87
return updatePromises [local ]
81
88
.then (function (nothing : Dynamic ) {
82
- trace (" promise fulfilled" );
89
+ trace (" INFO: promise fulfilled" );
83
90
callback (null );
84
91
}, function (err : Dynamic ) {
85
92
callback (err );
@@ -118,7 +125,7 @@ class Main {
118
125
if (params .isInfoRequest ) {
119
126
update (remote , local , function (err ) {
120
127
if (err != null ) {
121
- trace (' ERROR : $err ' );
128
+ trace (' ERR : $err ' );
122
129
trace (haxe. CallStack .toString (haxe. CallStack .exceptionStack ()));
123
130
res .statusCode = 500 ;
124
131
res .end ();
@@ -134,7 +141,7 @@ class Main {
134
141
up .on (" exit" , function (code ) {
135
142
if (code != 0 )
136
143
res .end ();
137
- trace (' ${params .service } done with exit $code ' );
144
+ trace (' INFO: ${params .service } done with exit $code ' );
138
145
});
139
146
});
140
147
} else {
@@ -190,8 +197,8 @@ Options:
190
197
if (listenPort == null || listenPort < 1 || listenPort > 65535 )
191
198
throw ' Invalid port number: ${options [" --port" ]}' ;
192
199
193
- trace (' cache directory: $cacheDir ' );
194
- trace (' listening to port: $listenPort ' );
200
+ trace (' INFO: cache directory: $cacheDir ' );
201
+ trace (' INFO: listening to port: $listenPort ' );
195
202
Http .createServer (handleRequest ).listen (listenPort );
196
203
}
197
204
}
0 commit comments