Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1 from microsoft/git_tag_support
Browse files Browse the repository at this point in the history
Added support for checking out git releases using tags after cloning …
  • Loading branch information
jowilco authored Mar 31, 2021
2 parents 0a9aa42 + 8b47646 commit 2ab54c7
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 5 deletions.
Binary file modified HtmlFromRepoGenerator/CustomPlugin.dll
Binary file not shown.
Binary file modified HtmlFromRepoGenerator/HtmlFromRepoGenerator.exe
Binary file not shown.
Binary file modified HtmlFromRepoGenerator/MainProcessor.dll
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ private void ValidateLogParameter(string paramName, string paramValue, LinkedLis
[System.ComponentModel.Description("URL of repository, e.g. https://github.com/MicrosoftDocs...")]
public string Repo { get; set; }

/// <summary>
/// Gets or sets the GitHub tag for a release.
/// </summary>
/// <value>
/// The GitHub tag for a release.
/// </value>
[CmdLineArg(ShowInUsage = DefaultBoolean.True, Usage = "v17.0")]
[System.ComponentModel.Description("GitHub tag for a release, e.g. v17.0")]
public string Tag { get; set; }

/// <summary>
/// Gets or sets a value indicating whether [remove git folder].
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private static void RunMain(CommandLineArguments parameters)
string clonedRepoPath = Path.Combine(parameters.Out, ".git");
if (!parameters.DoNotClone)
{
clonedRepoPath = CloneRepository(parameters.Repo, parameters.Out);
clonedRepoPath = CloneRepository(parameters.Repo, parameters.Out, parameters.Tag);
}

string enClonedRepoPath = null;
Expand All @@ -159,7 +159,7 @@ private static void RunMain(CommandLineArguments parameters)
enClonedRepoPath = Path.Combine(parameters.EnOut, ".git");
if (!String.IsNullOrEmpty(parameters.EnRepo))
{
enClonedRepoPath = CloneRepository(parameters.EnRepo, parameters.EnOut);
enClonedRepoPath = CloneRepository(parameters.EnRepo, parameters.EnOut, parameters.Tag);
}
}

Expand Down Expand Up @@ -388,11 +388,11 @@ private static void ProcessCopiedFiles(string baseDir, string baseUrl, string ba
/// <param name="url">The URL.</param>
/// <param name="dest">The dest.</param>
/// <returns></returns>
private static string CloneRepository(string url, string dest)
private static string CloneRepository(string url, string dest, string tag)
{
Logger.LogInfo($"Trying to clone {url}.");
CloneProcessor cloneProcessor = new CloneProcessor(Logger);
if (!cloneProcessor.TryCloneRepository(url, dest, percentCompleted =>
if (!cloneProcessor.TryCloneRepository(url, dest, tag, percentCompleted =>
{
Console.SetCursorPosition(0, Console.CursorTop);
Console.CursorVisible = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public CloneProcessor(ILogger logger)
/// <param name="handler">The handler.</param>
/// <param name="clonedRepoPath">The cloned repo path.</param>
/// <returns></returns>
public bool TryCloneRepository(string repoUrl, string outDir, CloneProgressHandler handler, out string clonedRepoPath)
public bool TryCloneRepository(string repoUrl, string outDir, string tag, CloneProgressHandler handler, out string clonedRepoPath)
{
_onProgress = handler;
_logger.LogInfo("Cloning repository is in progress. It may take awhile...");
Expand All @@ -49,6 +49,12 @@ public bool TryCloneRepository(string repoUrl, string outDir, CloneProgressHandl
try
{
clonedRepoPath = Repository.Clone(repoUrl, outDir, options);
if (!String.IsNullOrEmpty(tag))
{
_logger.LogInfo(Environment.NewLine + "Checking out " + tag);
Repository repo = new Repository(clonedRepoPath);
Commands.Checkout(repo, tag);
}
}
catch (Exception ex)
{
Expand Down

0 comments on commit 2ab54c7

Please sign in to comment.