Skip to content

Commit

Permalink
Managed implementation of git repo data reading
Browse files Browse the repository at this point in the history
  • Loading branch information
tmat committed Jun 19, 2019
1 parent 8144155 commit ce4ee16
Show file tree
Hide file tree
Showing 18 changed files with 3,337 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Expand Up @@ -3,7 +3,7 @@
<Import Project="Sdk.props" Sdk="Microsoft.DotNet.Arcade.Sdk" />

<PropertyGroup>
<LangVersion>Latest</LangVersion>
<LangVersion>Preview</LangVersion>
<Copyright>$(CopyrightMicrosoft)</Copyright>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<GenerateResxSource>true</GenerateResxSource>
Expand Down
14 changes: 5 additions & 9 deletions src/Microsoft.Build.Tasks.Git.Operations/GitOperations.cs
Expand Up @@ -26,8 +26,13 @@ public static string LocateRepository(string directory)
return Repository.Discover(directory);
}

internal static IRepository CreateRepository(string root)
=> new Repository(root);

public static string GetRepositoryUrl(IRepository repository, Action<string, object[]> logWarning = null, string remoteName = null)
{
// GetVariableValue("remote", name, "url");

var remotes = repository.Network.Remotes;
var remote = string.IsNullOrEmpty(remoteName) ? (remotes["origin"] ?? remotes.FirstOrDefault()) : remotes[remoteName];
if (remote == null)
Expand Down Expand Up @@ -179,15 +184,6 @@ public static ITaskItem[] GetSourceRoots(IRepository repository, Action<string,
}

// https://git-scm.com/docs/git-submodule
// <repository> is the URL of the new submodule's origin repository. This may be either an absolute URL, or (if it begins with ./ or ../),
// the location relative to the superproject's default remote repository (Please note that to specify a repository foo.git which is located
// right next to a superproject bar.git, you'll have to use ../foo.git instead of ./foo.git - as one might expect when following the rules
// for relative URLs -- because the evaluation of relative URLs in Git is identical to that of relative directories).
//
// The given URL is recorded into .gitmodules for use by subsequent users cloning the superproject.
// If the URL is given relative to the superproject's repository, the presumption is the superproject and submodule repositories
// will be kept together in the same relative location, and only the superproject's URL needs to be provided.git --
// submodule will correctly locate the submodule using the relative URL in .gitmodules.
var submoduleUrl = NormalizeUrl(submodule.Url, repoRoot);
if (submoduleUrl == null)
{
Expand Down
14 changes: 14 additions & 0 deletions src/Microsoft.Build.Tasks.Git.Operations/Managed/CharUtils.cs
@@ -0,0 +1,14 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;

namespace Microsoft.Build.Tasks.Git
{
internal static class CharUtils
{
public static char[] AsciiWhitespace = { ' ', '\t', '\n', '\f', '\r', '\v' };

public static bool IsHexadecimalDigit(char c)
=> c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f';
}
}

0 comments on commit ce4ee16

Please sign in to comment.