Skip to content

Commit 7c32eaf

Browse files
committed
Remove deprecated APIs
- Removed `GitRepoInspector.FromPath()` compatibility functions. - Removed `IRepoInspector.FetchTag(tag, remote)`. - Removed `IRepoInspector.GetParent(commit)`. - Removed `VersionCalculationOptions.MinimiumVersion`. - Added "remote" options to pass to the new core API. Meta: codecov only status reports on PRs.
1 parent 2bd0a7d commit 7c32eaf

13 files changed

+35
-73
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,13 @@ See [docs/VersionCalculation.md](docs/VersionCalculation.md) for further reading
5353
| The minimum RTM version, i.e the destined version. | -m, --min-version, VerliteMinimumVersion | 0.1.0 |
5454
| The height for continuous deliverable auto heights should begin at. | -p, --prerelease-base-height, VerlitePrereleaseBaseHeight | 1 |
5555
| Force the calculated version to be this version. | --version-override, VerliteVersionOverride | |
56-
| Logging level. | --verbosity, VerliteVerbosity | Normal |
56+
| Logging level. | --verbosity, VerliteVerbosity | normal |
5757
| Set the build data to this value. | -b, --build-metadata, VerliteBuildMetadata | |
58-
| Part of the version to print. | -s, --show | All |
58+
| Part of the version to print. | -s, --show | all |
5959
| Automatically fetch commits and a tag for shallow clones. | --auto-fetch | false |
6060
| Set which version part should be bumped after an RTM release. | -a, --auto-increment, VerliteAutoIncrement | patch |
6161
| A command to test whether a tag should be ignored via exit code. | -f, --filter-tags, VerliteFilterTags | |
62+
| The remote endpoint to use when fetching tags and commits. | -r, --remote, VerliteRemote | origin |
6263

6364
## Comparison with GitVersion
6465

codecov.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
comment: false
1+
comment: false
2+
coverage:
3+
status:
4+
project:
5+
default:
6+
only_pulls: true
7+
patch:
8+
default:
9+
only_pulls: true

src/Verlite.CLI/Program.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ public static async Task<int> Main(string[] args)
9090
aliases: new[] { "--filter-tags", "-f" },
9191
getDefaultValue: () => string.Empty,
9292
description: "Specify a command to execute, an exit code of 0 will not filter the tag."),
93+
new Option<string>(
94+
aliases: new[] { "--remote", "-r" },
95+
getDefaultValue: () => DefaultOptions.Remote,
96+
description: "The remote endpoint to use when fetching tags and commits."),
9397
};
9498
rootCommand.WithHandler(nameof(RootCommandAsync));
9599
return await rootCommand.InvokeAsync(args);
@@ -107,6 +111,7 @@ private async static Task RootCommandAsync(
107111
bool autoFetch,
108112
AutoIncrement autoIncrement,
109113
string filterTags,
114+
string remote,
110115
string sourceDirectory)
111116
{
112117
try
@@ -127,12 +132,13 @@ private async static Task RootCommandAsync(
127132
BuildMetadata = buildMetadata,
128133
QueryRemoteTags = autoFetch,
129134
AutoIncrement = autoIncrement.Value(),
135+
Remote = remote,
130136
};
131137

132138
var version = opts.VersionOverride ?? new SemVer();
133139
if (opts.VersionOverride is null)
134140
{
135-
using var repo = await GitRepoInspector.FromPath(sourceDirectory, log, commandRunner);
141+
using var repo = await GitRepoInspector.FromPath(sourceDirectory, opts.Remote, log, commandRunner);
136142
repo.CanDeepen = autoFetch;
137143

138144
ITagFilter? tagFilter = null;

src/Verlite.Core/GitRepoInspector.cs

+1-21
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,6 @@ public UnknownGitException(string message) : base(message) { }
3838
/// <seealso cref="IRepoInspector"/>
3939
public sealed class GitRepoInspector : IRepoInspector, IDisposable
4040
{
41-
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
42-
// TODO: Remove all of these enumerated permutations of the old optional args in 2.0.0
43-
[ExcludeFromCodeCoverage]
44-
[Obsolete("Use FromPath(path, remote, log, commandRunner)", error: false)]
45-
public static Task<GitRepoInspector> FromPath(string path, ILogger? log, ICommandRunner? commandRunner)
46-
=> FromPath(path, "origin", log, commandRunner ?? new SystemCommandRunner());
47-
[ExcludeFromCodeCoverage]
48-
[Obsolete("Use FromPath(path, remote, log, commandRunner)", error: false)]
49-
public static Task<GitRepoInspector> FromPath(string path, ILogger? log)
50-
=> FromPath(path, "origin", log, new SystemCommandRunner());
51-
[ExcludeFromCodeCoverage]
52-
[Obsolete("Use FromPath(path, remote, log, commandRunner)", error: false)]
53-
public static Task<GitRepoInspector> FromPath(string path, ICommandRunner? commandRunner)
54-
=> FromPath(path, "origin", null, commandRunner?? new SystemCommandRunner());
55-
[ExcludeFromCodeCoverage]
56-
[Obsolete("Use FromPath(path, remote, log, commandRunner)", error: false)]
57-
public static Task<GitRepoInspector> FromPath(string path)
58-
=> FromPath(path, "origin", null, new SystemCommandRunner());
59-
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
60-
6141
/// <summary>
6242
/// Creates an inspector from the specified path.
6343
/// </summary>
@@ -347,7 +327,7 @@ public async Task<IReadOnlyList<Commit>> GetParents(Commit commit)
347327
return parents;
348328
}
349329

350-
private static readonly Regex RefsTagRegex = new Regex(
330+
private static readonly Regex RefsTagRegex = new(
351331
@"^(?<pointer>[a-zA-Z0-9]+)\s*refs/tags/(?<tag>.+?)(\^\{\})?$",
352332
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.ExplicitCapture);
353333
private static IEnumerable<Tag> MatchTags(string commandOutput)

src/Verlite.Core/IRepoInspector.cs

-15
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,6 @@ public interface IRepoInspector
7070
/// <returns>A task containing the commit, or <c>null</c> if there is none.</returns>
7171
Task<Commit?> GetHead();
7272
/// <summary>
73-
/// Gets the primary parent of the specified commit. <br/>
74-
/// In DVCSs this is typically the first parent.
75-
/// </summary>
76-
/// <param name="commit">The commit.</param>
77-
/// <returns>A task containing the primary parent commit, or <c>null</c> if it has none.</returns>
78-
[Obsolete("Deprecated in favor of GetParents(). See GitHub issue #40.", error: false)]
79-
Task<Commit?> GetParent(Commit commit);
80-
/// <summary>
8173
/// Gets all parents of the specified commit.
8274
/// </summary>
8375
/// <param name="commit">The commit.</param>
@@ -90,13 +82,6 @@ public interface IRepoInspector
9082
/// <returns>A task containing a <see cref="TagContainer"/></returns>
9183
Task<TagContainer> GetTags(QueryTarget queryTarget);
9284
/// <summary>
93-
/// Fetches the specified tag from the desired remote.
94-
/// </summary>
95-
/// <param name="tag">The tag to fetch.</param>
96-
/// <param name="remote">Which remote to fetch the tag from.</param>
97-
[Obsolete("Use FetchTag(tag)", error: false)]
98-
Task FetchTag(Tag tag, string remote);
99-
/// <summary>
10085
/// Fetches the specified tag from the remote.
10186
/// </summary>
10287
/// <param name="tag">The tag to fetch.</param>

src/Verlite.Core/PublicAPI.Shipped.txt

-8
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ static Verlite.Command.ParseCommandLine(string! cmdLine) -> System.Collections.G
1414
static Verlite.Command.Run(string! directory, string! command, string![]! args, System.Collections.Generic.IDictionary<string!, string!>? envVars = null) -> System.Threading.Tasks.Task<(string! stdout, string! stderr)>!
1515
static Verlite.Commit.operator !=(Verlite.Commit left, Verlite.Commit right) -> bool
1616
static Verlite.Commit.operator ==(Verlite.Commit left, Verlite.Commit right) -> bool
17-
static Verlite.GitRepoInspector.FromPath(string! path) -> System.Threading.Tasks.Task<Verlite.GitRepoInspector!>!
1817
static Verlite.GitRepoInspector.FromPath(string! path, string! remote, Verlite.ILogger? log, Verlite.ICommandRunner! commandRunner) -> System.Threading.Tasks.Task<Verlite.GitRepoInspector!>!
19-
static Verlite.GitRepoInspector.FromPath(string! path, Verlite.ICommandRunner? commandRunner) -> System.Threading.Tasks.Task<Verlite.GitRepoInspector!>!
20-
static Verlite.GitRepoInspector.FromPath(string! path, Verlite.ILogger? log) -> System.Threading.Tasks.Task<Verlite.GitRepoInspector!>!
21-
static Verlite.GitRepoInspector.FromPath(string! path, Verlite.ILogger? log, Verlite.ICommandRunner? commandRunner) -> System.Threading.Tasks.Task<Verlite.GitRepoInspector!>!
2218
static Verlite.HeightCalculator.FromRepository(Verlite.IRepoInspector! repo, string! tagPrefix, bool queryRemoteTags, Verlite.ILogger? log = null, Verlite.ITagFilter? tagFilter = null) -> System.Threading.Tasks.Task<(int height, Verlite.TaggedVersion?)>!
2319
static Verlite.SemVer.ComparePrerelease(string! left, string! right) -> int
2420
static Verlite.SemVer.IsValidIdentifierCharacter(char input) -> bool
@@ -77,9 +73,7 @@ Verlite.ILogger.Verbatim(string! message) -> void
7773
Verlite.ILogger.Verbose(string! message) -> void
7874
Verlite.IRepoInspector
7975
Verlite.IRepoInspector.FetchTag(Verlite.Tag tag) -> System.Threading.Tasks.Task!
80-
Verlite.IRepoInspector.FetchTag(Verlite.Tag tag, string! remote) -> System.Threading.Tasks.Task!
8176
Verlite.IRepoInspector.GetHead() -> System.Threading.Tasks.Task<Verlite.Commit?>!
82-
Verlite.IRepoInspector.GetParent(Verlite.Commit commit) -> System.Threading.Tasks.Task<Verlite.Commit?>!
8377
Verlite.IRepoInspector.GetParents(Verlite.Commit commit) -> System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Verlite.Commit>!>!
8478
Verlite.IRepoInspector.GetTags(Verlite.QueryTarget queryTarget) -> System.Threading.Tasks.Task<Verlite.TagContainer!>!
8579
Verlite.ITagFilter
@@ -143,8 +137,6 @@ Verlite.VersionCalculationOptions.BuildMetadata.get -> string?
143137
Verlite.VersionCalculationOptions.BuildMetadata.set -> void
144138
Verlite.VersionCalculationOptions.DefaultPrereleasePhase.get -> string!
145139
Verlite.VersionCalculationOptions.DefaultPrereleasePhase.set -> void
146-
Verlite.VersionCalculationOptions.MinimiumVersion.get -> Verlite.SemVer
147-
Verlite.VersionCalculationOptions.MinimiumVersion.set -> void
148140
Verlite.VersionCalculationOptions.MinimumVersion.get -> Verlite.SemVer
149141
Verlite.VersionCalculationOptions.MinimumVersion.set -> void
150142
Verlite.VersionCalculationOptions.PrereleaseBaseHeight.get -> int

src/Verlite.Core/PublicAPI.Unshipped.txt

+2
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ Verlite.GitRepoInspector.Dispose() -> void
33
Verlite.GitRepoInspector.Remote.get -> string!
44
Verlite.UnknownGitException
55
Verlite.UnknownGitException.UnknownGitException(string! message) -> void
6+
Verlite.VersionCalculationOptions.Remote.get -> string!
7+
Verlite.VersionCalculationOptions.Remote.set -> void

src/Verlite.Core/VersionCalculationOptions.cs

+2-8
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,9 @@ public class VersionCalculationOptions
4141
/// The component to bump in the semantic version post RTM release.
4242
/// </summary>
4343
public VersionPart AutoIncrement { get; set; } = VersionPart.Patch;
44-
4544
/// <summary>
46-
/// Obsoleted due to a typo. Using this will redirect to the suggested replacement of <see cref="MinimumVersion"/> instead.
45+
/// The remote endpoint to use when fetching tags and commits.
4746
/// </summary>
48-
[Obsolete("Use MinimumVersion instead.")]
49-
public SemVer MinimiumVersion
50-
{
51-
get => MinimumVersion;
52-
set => MinimumVersion = value;
53-
}
47+
public string Remote { get; set; } = "origin";
5448
}
5549
}

src/Verlite.Core/VersionCalculator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public static async Task<SemVer> FromRepository(
113113
if (!localTag.Any())
114114
{
115115
log?.Normal("Local repo missing version tag, fetching.");
116-
await repo.FetchTag(lastTagVer.Tag, "origin");
116+
await repo.FetchTag(lastTagVer.Tag);
117117
}
118118
}
119119

src/Verlite.MsBuild/GetVersionTask.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public sealed partial class GetVersionTask : MsBuildTask
2020
public string PrereleaseBaseHeight { get; set; } = "";
2121
public string AutoIncrement { get; set; } = "";
2222
public string FilterTags { get; set; } = "";
23+
public string Remote { get; set; } = "";
2324

2425
public override bool Execute()
2526
{
@@ -101,12 +102,15 @@ private async Task<bool> ExecuteAsync()
101102
if (!string.IsNullOrWhiteSpace(AutoIncrement))
102103
opts.AutoIncrement = DecodeVersionPart(
103104
AutoIncrement, nameof(AutoIncrement));
105+
106+
if (!string.IsNullOrWhiteSpace(Remote))
107+
opts.Remote = Remote;
104108
}
105109

106110
var version = opts.VersionOverride ?? new SemVer();
107111
if (opts.VersionOverride is null)
108112
{
109-
using var repo = await GitRepoInspector.FromPath(ProjectDirectory, log, commandRunner);
113+
using var repo = await GitRepoInspector.FromPath(ProjectDirectory, opts.Remote, log, commandRunner);
110114

111115
ITagFilter? tagFilter = null;
112116
if (!string.IsNullOrWhiteSpace(FilterTags))

src/Verlite.MsBuild/build/Verlite.MsBuild.targets

+3-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ This file has been modified by Ashleigh Adams and adapted for Verlite -->
4343
<Message Importance="$(VerliteDetailed)" Text="Verlite: [input] VerlitePrereleaseBaseHeight=$(VerlitePrereleaseBaseHeight)" />
4444
<Message Importance="$(VerliteDetailed)" Text="Verlite: [input] VerliteAutoIncrement=$(VerliteAutoIncrement)" />
4545
<Message Importance="$(VerliteDetailed)" Text="Verlite: [input] VerliteFilterTags=$(VerliteFilterTags)" />
46+
<Message Importance="$(VerliteDetailed)" Text="Verlite: [input] VerliteRemote=$(VerliteRemote)" />
4647

4748
<Verlite.MsBuild.GetVersionTask ProjectDirectory="$(MSBuildProjectDirectory)"
4849
BuildMetadata="$(VerliteBuildMetadata)"
@@ -54,7 +55,8 @@ This file has been modified by Ashleigh Adams and adapted for Verlite -->
5455
VersionOverride="$(VerliteVersionOverride)"
5556
PrereleaseBaseHeight="$(VerlitePrereleaseBaseHeight)"
5657
AutoIncrement="$(VerliteAutoIncrement)"
57-
FilterTags="$(VerliteFilterTags)" >
58+
FilterTags="$(VerliteFilterTags)"
59+
Remote="$(VerliteRemote)" >
5860
<Output TaskParameter="Version" PropertyName="VerliteVersion" />
5961
<Output TaskParameter="VersionMajor" PropertyName="VerliteMajor" />
6062
<Output TaskParameter="VersionMinor" PropertyName="VerliteMinor" />

tests/UnitTests/GitRepoInspectorTests.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ public Task<GitRepoInspector> MakeInspector(ICommandRunner? commandRunner = null
5757
{
5858
return GitRepoInspector.FromPath(
5959
path: RootPath,
60+
remote: "origin",
6061
log: null,
61-
commandRunner);
62+
commandRunner ?? new SystemCommandRunner());
6263
}
6364

6465
public void Dispose()

tests/UnitTests/Mocks/MockRepoInspector.cs

-13
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,6 @@ public MockRepoInspector(IReadOnlyList<MockRepoCommit> commits)
133133
Head = commits.Count > 0 ? commits[0].Id : null;
134134
}
135135

136-
Task IRepoInspector.FetchTag(Tag tag, string remote)
137-
{
138-
return (this as IRepoInspector).FetchTag(tag);
139-
}
140-
141136
async Task IRepoInspector.FetchTag(Tag tag)
142137
{
143138
if (LocalTags.Contains(tag))
@@ -151,14 +146,6 @@ async Task IRepoInspector.FetchTag(Tag tag)
151146
return Head;
152147
}
153148

154-
async Task<Commit?> IRepoInspector.GetParent(Commit commit)
155-
{
156-
var parents = await (this as IRepoInspector).GetParents(commit);
157-
return parents
158-
.Select(p => (Commit?)p)
159-
.FirstOrDefault();
160-
}
161-
162149
async Task<IReadOnlyList<Commit>> IRepoInspector.GetParents(Commit commit)
163150
{
164151
return Commits[commit].Parents;

0 commit comments

Comments
 (0)