Skip to content
This repository was archived by the owner on May 7, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion NetRevisionTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,9 @@ private static void MainWrapper()
/// <param name="severity">0 (trace message), 1 (success), 2 (warning), 3 (error), 4 (raw output).</param>
public static void ShowDebugMessage(string text, int severity = 0)
{
if (text == null)
return;

if (showDebugOutput)
{
var color = Console.ForegroundColor;
Expand Down Expand Up @@ -407,7 +410,7 @@ private static RevisionData ProcessDirectory(string path, bool scanRoot, string
ShowDebugMessage("Root directory will be scanned.", 0);
path = rootPath;
}
data = provider.ProcessDirectory(path);
data = provider.ProcessDirectory(path, rootPath);
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions NetRevisionTool/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
[assembly: AssemblyCompany("unclassified software development")]

// Assembly identity version. Must be a dotted-numeric version.
[assembly: AssemblyVersion("2.6.2")]
[assembly: AssemblyVersion("2.6.3")]

// Repeat for Win32 file version resource because the assembly version is expanded to 4 parts.
[assembly: AssemblyFileVersion("2.6.2")]
[assembly: AssemblyFileVersion("2.6.3")]

// Indicate the build configuration
#if DEBUG
Expand Down
5 changes: 5 additions & 0 deletions NetRevisionTool/RevisionData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ internal class RevisionData
/// </summary>
public int CommitsAfterTag { get; set; }

/// <summary>
/// The name of the parent containing repository folder, this is usually the same as the name of the hosted repo.
/// </summary>
public string RepoRootFolder { get; set; }

#endregion Revision data properties

#region Operations
Expand Down
26 changes: 17 additions & 9 deletions NetRevisionTool/RevisionFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public string Resolve(string format)
format = format.Replace("{amail}", RevisionData.AuthorEMail);
format = format.Replace("{mname}", Environment.MachineName);

if (RevisionData.RepoRootFolder != String.Empty)
format = format.Replace("{repodir}", RevisionData.RepoRootFolder);

if (!string.IsNullOrEmpty(RevisionData.Branch))
{
format = format.Replace("{branch}", RevisionData.Branch);
Expand Down Expand Up @@ -167,7 +170,12 @@ private string FormatTimeScheme(Match match)
case SchemeType.Readable:
if (data.Utc)
{
time = time.UtcDateTime;
// This code is specific to Arizona - it gets MST then uses that to get MST with daylight saving disabled.
// SEE: https://stackoverflow.com/questions/12266948/remove-dst-from-datetime
var zone = TimeZoneInfo.FindSystemTimeZoneById("Mountain Standard Time");
var newzone = TimeZoneInfo.CreateCustomTimeZone(zone.Id, zone.BaseUtcOffset, zone.DisplayName, zone.StandardName, "", null, true);
time = time.UtcDateTime;
time = TimeZoneInfo.ConvertTimeFromUtc(time.DateTime, newzone);
}
return time.ToString(data.TimeFormat, CultureInfo.InvariantCulture);

Expand All @@ -185,16 +193,16 @@ private string FormatTimeScheme(Match match)
return scheme;
}

#endregion Format resolving
#endregion Format resolving

#region Scheme parsing
#region Scheme parsing

/// <summary>
/// Parses a version scheme specification.
/// </summary>
/// <param name="scheme">The version scheme specification to parse.</param>
/// <returns>The parsed scheme data.</returns>
private static SchemeData ParseScheme(string scheme)
/// <summary>
/// Parses a version scheme specification.
/// </summary>
/// <param name="scheme">The version scheme specification to parse.</param>
/// <returns>The parsed scheme data.</returns>
private static SchemeData ParseScheme(string scheme)
{
SchemeData data = new SchemeData();

Expand Down
27 changes: 21 additions & 6 deletions NetRevisionTool/VcsProviders/GitProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,20 @@ public bool CheckDirectory(string path, out string rootPath)
return false;
}

public RevisionData ProcessDirectory(string path)
public RevisionData ProcessDirectory(string path, string repoRoot)
{
// Initialise data
RevisionData data = new RevisionData
{
VcsProvider = this
string repositoryRoot = "";

if (String.IsNullOrWhiteSpace(repoRoot) == false)
{
repositoryRoot = Path.GetFileName(repoRoot);
}

// Initialise data
RevisionData data = new RevisionData
{
VcsProvider = this,
RepoRootFolder = repositoryRoot
};

// Queries the commit hash and time from the latest log entry
Expand Down Expand Up @@ -140,13 +148,20 @@ public RevisionData ProcessDirectory(string path)
line = null;
while (!p.StandardOutput.EndOfStream)
{
line = p.StandardOutput.ReadLine();
string templine = p.StandardOutput.ReadLine();

// Do not consider this line if it contans any of the file names that can, conceivably appear in the status due to the tool itself.

if (!(templine.Contains("AssemblyInfo.cs") || templine.Contains("AssemblyInfo.vb") || templine.Contains("AssemblyInfo.bak")))
line = templine;

Program.ShowDebugMessage(line, 4);
}
if (!p.WaitForExit(1000))
{
p.Kill();
}

data.IsModified = !string.IsNullOrEmpty(line);

// Query the current branch
Expand Down
2 changes: 1 addition & 1 deletion NetRevisionTool/VcsProviders/IVcsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ internal interface IVcsProvider
/// </summary>
/// <param name="path">The directory to process.</param>
/// <returns>The data about the revision found in the directory.</returns>
RevisionData ProcessDirectory(string path);
RevisionData ProcessDirectory(string path, string repoRoot);
}
}
11 changes: 6 additions & 5 deletions NetRevisionTool/VcsProviders/SubversionProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,13 @@ public bool CheckDirectory(string path, out string rootPath)
return false;
}

public RevisionData ProcessDirectory(string path)
public RevisionData ProcessDirectory(string path, string repoRoot)
{
// Initialise data
RevisionData data = new RevisionData
{
VcsProvider = this
// Initialise data
RevisionData data = new RevisionData
{
VcsProvider = this,
RepoRootFolder = "" // Not yet implemneted as it is in GitProvider.
};

// svn assumes case-sensitive path names on Windows, which is... bad.
Expand Down