Skip to content

Commit ce4ee16

Browse files
committed
Managed implementation of git repo data reading
1 parent 8144155 commit ce4ee16

18 files changed

+3337
-13
lines changed

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Import Project="Sdk.props" Sdk="Microsoft.DotNet.Arcade.Sdk" />
44

55
<PropertyGroup>
6-
<LangVersion>Latest</LangVersion>
6+
<LangVersion>Preview</LangVersion>
77
<Copyright>$(CopyrightMicrosoft)</Copyright>
88
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
99
<GenerateResxSource>true</GenerateResxSource>

src/Microsoft.Build.Tasks.Git.Operations/GitOperations.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@ public static string LocateRepository(string directory)
2626
return Repository.Discover(directory);
2727
}
2828

29+
internal static IRepository CreateRepository(string root)
30+
=> new Repository(root);
31+
2932
public static string GetRepositoryUrl(IRepository repository, Action<string, object[]> logWarning = null, string remoteName = null)
3033
{
34+
// GetVariableValue("remote", name, "url");
35+
3136
var remotes = repository.Network.Remotes;
3237
var remote = string.IsNullOrEmpty(remoteName) ? (remotes["origin"] ?? remotes.FirstOrDefault()) : remotes[remoteName];
3338
if (remote == null)
@@ -179,15 +184,6 @@ public static ITaskItem[] GetSourceRoots(IRepository repository, Action<string,
179184
}
180185

181186
// https://git-scm.com/docs/git-submodule
182-
// <repository> is the URL of the new submodule's origin repository. This may be either an absolute URL, or (if it begins with ./ or ../),
183-
// the location relative to the superproject's default remote repository (Please note that to specify a repository foo.git which is located
184-
// 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
185-
// for relative URLs -- because the evaluation of relative URLs in Git is identical to that of relative directories).
186-
//
187-
// The given URL is recorded into .gitmodules for use by subsequent users cloning the superproject.
188-
// If the URL is given relative to the superproject's repository, the presumption is the superproject and submodule repositories
189-
// will be kept together in the same relative location, and only the superproject's URL needs to be provided.git --
190-
// submodule will correctly locate the submodule using the relative URL in .gitmodules.
191187
var submoduleUrl = NormalizeUrl(submodule.Url, repoRoot);
192188
if (submoduleUrl == null)
193189
{
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
2+
3+
using System;
4+
5+
namespace Microsoft.Build.Tasks.Git
6+
{
7+
internal static class CharUtils
8+
{
9+
public static char[] AsciiWhitespace = { ' ', '\t', '\n', '\f', '\r', '\v' };
10+
11+
public static bool IsHexadecimalDigit(char c)
12+
=> c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f';
13+
}
14+
}

0 commit comments

Comments
 (0)