Skip to content

Commit b4e194a

Browse files
authored
Merge pull request #295 from leeebo/fix/git_mirror_jihulab
fix(jihulab): redirect the submodules' URL from github to jihulab
2 parents a865e5d + b8d0eb2 commit b4e194a

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/InnoSetup/Environment.iss

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ var
293293
IDFTempPath: String;
294294
IDFPath: String;
295295
NeedToClone: Boolean;
296+
ResultCode: Integer;
296297
begin
297298
IDFPath := IDFDownloadPath;
298299
{ If there is a release archive to download, IDFZIPFileName and IDFZIPFileVersion will be set.
@@ -336,6 +337,10 @@ begin
336337
GitUseMirror := False;
337338
IsGitRecursive := True;
338339
GitRepository := 'https://jihulab.com/esp-mirror/espressif/esp-idf.git';
340+
{ Some submodules's submodule using absolute github url, redirect to jihulab }
341+
if Exec(GitExecutablePath, + ' config --global url.https://jihulab.com/esp-mirror.insteadOf https://github.com', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then begin
342+
Log('Git URLs redirect to jihulab.com succeeded');
343+
end;
339344
end;
340345
341346
CmdLine := GitExecutablePath + ' clone --progress -b ' + IDFDownloadVersion;
@@ -350,7 +355,25 @@ begin
350355
351356
CmdLine := CmdLine + ' ' + GitRepository +' "' + IDFPath + '"';
352357
Log('Cloning IDF: ' + CmdLine);
353-
DoCmdlineInstall(CustomMessage('DownloadingEspIdf'), CustomMessage('UsingGitToClone'), CmdLine);
358+
359+
if PerformCmdlineInstall(CustomMessage('DownloadingEspIdf'), CustomMessage('UsingGitToClone'), CmdLine) then begin
360+
Log('Git clone completed');
361+
end else begin
362+
if (WizardIsComponentSelected('{#COMPONENT_OPTIMIZATION_GIT_MIRROR_JIHULAB}')) then begin
363+
{ Unset the redirect url before the exception return }
364+
if Exec(GitExecutablePath, + ' config --global --unset url.https://jihulab.com/esp-mirror.insteadOf', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then begin
365+
Log('Git URLs redirect to jihulab.com removed');
366+
end;
367+
end;
368+
RaiseException(CustomMessage('InstallationFailedAtStep') + ' ' + CustomMessage('DownloadingEspIdf'));
369+
end;
370+
371+
if (WizardIsComponentSelected('{#COMPONENT_OPTIMIZATION_GIT_MIRROR_JIHULAB}')) then begin
372+
{ Unset the redirect url after the clone }
373+
if Exec(GitExecutablePath, + ' config --global --unset url.https://jihulab.com/esp-mirror.insteadOf', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then begin
374+
Log('Git URLs redirect to jihulab.com removed');
375+
end;
376+
end;
354377
355378
if (GitUseMirror) then begin
356379
ApplyIdfMirror(IDFPath, GitRepository, GitSubmoduleUrl);

0 commit comments

Comments
 (0)