forked from dotnet/android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[xaprepare] Update ExternalGitDependency usage (#2)
Allows a non-authorized https-based clone for local use cases, and cleans up various logging events to ensure we don't leak secrets. Also includes some minor azure-pipelines.yaml cleanup.
- Loading branch information
Showing
6 changed files
with
64 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,6 @@ sealed class ExternalGitDependency : AppObject | |
public string Commit { get; private set; } | ||
public string Name { get; private set; } | ||
public string Owner { get; private set; } | ||
public string Url { get; private set; } | ||
|
||
public static List<ExternalGitDependency> GetDependencies (Context context, string externalFilePath) | ||
{ | ||
|
@@ -54,22 +53,12 @@ public static List<ExternalGitDependency> GetDependencies (Context context, stri | |
Name = match.Groups["repo"].Value, | ||
Owner = match.Groups["owner"].Value, | ||
}; | ||
SetGitHubURL (e); | ||
externals.Add (e); | ||
Log.Instance.StatusLine ($" {context.Characters.Bullet} {e.Owner}/{e.Name} ({e.Commit})"); | ||
} | ||
} | ||
|
||
return externals; | ||
} | ||
|
||
static void SetGitHubURL (ExternalGitDependency egd) | ||
{ | ||
string ghToken = Environment.GetEnvironmentVariable ("GH_AUTH_SECRET"); | ||
if (!String.IsNullOrEmpty (ghToken)) | ||
egd.Url = $"https://{ghToken}@github.com:/{egd.Owner}/{egd.Name}"; | ||
else | ||
egd.Url = $"[email protected]:/{egd.Owner}/{egd.Name}"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,20 +18,23 @@ protected override async Task<bool> Execute (Context context) | |
bool failed = false; | ||
Log.StatusLine (); | ||
Log.StatusLine ("Updating external repositories"); | ||
var git = new GitRunner (context); | ||
var git = new GitRunner (context) { | ||
EchoCmdAndArguments = false | ||
}; | ||
foreach (ExternalGitDependency egd in externalDependencies) { | ||
Log.StatusLine ($" {context.Characters.Bullet} {egd.Name}"); | ||
string destDir = Path.Combine (Configurables.Paths.ExternalGitDepsDestDir, egd.Name); | ||
if (!Directory.Exists (destDir)) { | ||
Log.StatusLine ($" {context.Characters.Link} cloning from {egd.Url}"); | ||
if (!await git.Clone (egd.Url, destDir)) { | ||
var egdUrl = await GetGitHubURL (egd, git); | ||
Log.StatusLine ($" {context.Characters.Link} cloning from {egd.Owner}/{egd.Name}"); | ||
if (!await git.Clone (egdUrl, destDir)) { | ||
Log.ErrorLine ($"Failed to clone {egd.Name}"); | ||
failed = true; | ||
continue; | ||
} | ||
} | ||
|
||
Log.StatusLine ($" {context.Characters.Link} fetching changes from {egd.Url}"); | ||
Log.StatusLine ($" {context.Characters.Link} fetching changes from {egd.Owner}/{egd.Name}"); | ||
if (!await git.Fetch (destDir)) { | ||
Log.ErrorLine ($"Failed to fetch changes for {egd.Name}"); | ||
failed = true; | ||
|
@@ -65,5 +68,19 @@ protected override async Task<bool> Execute (Context context) | |
|
||
return !failed; | ||
} | ||
|
||
async Task<string> GetGitHubURL (ExternalGitDependency egd, GitRunner git) | ||
{ | ||
string ghToken = Environment.GetEnvironmentVariable("GH_AUTH_SECRET"); | ||
if (!String.IsNullOrEmpty (ghToken)) { | ||
return $"https://{ghToken}@github.com:/{egd.Owner}/{egd.Name}"; | ||
} else { | ||
if (await git.IsRepoUrlHttps (BuildPaths.XamarinAndroidSourceRoot)) { | ||
return $"https://github.com:/{egd.Owner}/{egd.Name}"; | ||
} else { | ||
return $"[email protected]:/{egd.Owner}/{egd.Name}"; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters