forked from dotnet/Nerdbank.GitVersioning
-
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.
- Loading branch information
Showing
7 changed files
with
94 additions
and
7 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
36 changes: 36 additions & 0 deletions
36
src/NerdBank.GitVersioning/DisabledGit/DisabledGitContext.cs
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#nullable enable | ||
|
||
using System; | ||
using System.Diagnostics; | ||
|
||
namespace Nerdbank.GitVersioning | ||
{ | ||
[DebuggerDisplay("{" + nameof(DebuggerDisplay) + ",nq}")] | ||
internal class DisabledGitContext : GitContext | ||
{ | ||
public DisabledGitContext(string workingTreePath) | ||
: base(workingTreePath, null) | ||
{ | ||
this.VersionFile = new DisabledGitVersionFile(this); | ||
} | ||
|
||
public override VersionFile VersionFile { get; } | ||
|
||
public override string? GitCommitId => null; | ||
|
||
public override bool IsHead => false; | ||
|
||
public override DateTimeOffset? GitCommitDate => null; | ||
|
||
public override string? HeadCanonicalName => null; | ||
|
||
private string DebuggerDisplay => $"\"{this.WorkingTreePath}\" (no-git)"; | ||
|
||
public override void ApplyTag(string name) => throw new NotSupportedException(); | ||
public override void Stage(string path) => throw new NotSupportedException(); | ||
public override string GetShortUniqueCommitId(int minLength) => "nerdbankdisabled"; | ||
public override bool TrySelectCommit(string committish) => true; | ||
internal override int CalculateVersionHeight(VersionOptions? committedVersion, VersionOptions? workingVersion) => 0; | ||
internal override Version GetIdAsVersion(VersionOptions? committedVersion, VersionOptions? workingVersion, int versionHeight) => Version0; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/NerdBank.GitVersioning/DisabledGit/DisabledGitVersionFile.cs
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace Nerdbank.GitVersioning | ||
{ | ||
using Validation; | ||
|
||
internal class DisabledGitVersionFile : VersionFile | ||
{ | ||
public DisabledGitVersionFile(GitContext context) | ||
: base(context) | ||
{ | ||
} | ||
|
||
protected new DisabledGitContext Context => (DisabledGitContext)base.Context; | ||
|
||
protected override VersionOptions GetVersionCore(out string actualDirectory) | ||
{ | ||
actualDirectory = null; | ||
return null; | ||
} | ||
} | ||
} |
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
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