Skip to content

Commit

Permalink
Option to not warn on missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredpar committed Jul 6, 2017
1 parent 26fb807 commit b5af8e8
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/GitLink/Extensions/RepositoryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal static class RepositoryExtensions
private static readonly ILog Log = LogManager.GetCurrentClassLogger();
private static readonly char[] PathSeparators = new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar };

internal static string GetNormalizedPath(this Repository repository, string path)
internal static string GetNormalizedPath(this Repository repository, string path, bool warnOnMissingFiles = true)
{
Argument.IsNotNull(nameof(repository), repository);
Argument.IsNotNullOrEmpty(nameof(path), path);
Expand All @@ -39,7 +39,11 @@ internal static string GetNormalizedPath(this Repository repository, string path

if (entry == null)
{
Log.Warning($"Unable to find file in git: \"{path}\".");
if (warnOnMissingFiles)
{
Log.Warning($"Unable to find file in git: \"{path}\".");
}

return path;
}

Expand Down
2 changes: 2 additions & 0 deletions src/GitLink/LinkOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public struct LinkOptions

public bool SkipVerify { get; set; }

public bool SkipWarningOnMissingFiles { get; set; }

public Uri GitRemoteUrl { get; set; }

public string CommitId { get; set; }
Expand Down
3 changes: 2 additions & 1 deletion src/GitLink/Linker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ public static bool Link(string pdbPath, LinkOptions options = default(LinkOption
try
{
Repository repo = repository.Value;
repoSourceFiles = sourceFiles.ToDictionary(e => e, e => repo.GetNormalizedPath(e));
var warnOnMissingFiles = !options.SkipWarningOnMissingFiles;
repoSourceFiles = sourceFiles.ToDictionary(e => e, e => repo.GetNormalizedPath(e, warnOnMissingFiles));
}
catch (RepositoryNotFoundException)
{
Expand Down
1 change: 1 addition & 0 deletions src/GitLinkTask/GitLink.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<PropertyGroup>
<GitLinkEnabled Condition=" '$(DesignTimeBuild)' != 'true' and '$(Configuration)' == 'Release' and '$(GitLinkEnabled)' == '' and $(BuildingForLiveUnitTesting) != 'true' ">true</GitLinkEnabled>
<GitLinkContinueOnError>true</GitLinkContinueOnError>
<GitLinkWarnOnMissingFiles>true</GitLinkWarnOnMissingFiles>
</PropertyGroup>
</Project>
1 change: 1 addition & 0 deletions src/GitLinkTask/GitLink.targets
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
GitRemoteUrl="$(GitLinkGitRemoteUrl)"
GitWorkingDirectory="$(GitWorkingDirectory)"
GitCommitId="$(GitCommitId)"
WarnOnMissingFiles="$(GitLinkWarnOnMissingFiles)"
ContinueOnError="$(GitLinkContinueOnError)" />
</Target>
</Project>
3 changes: 3 additions & 0 deletions src/GitLinkTask/LinkPdbToGitRemote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public string Method

public string GitWorkingDirectory { get; set; }

public bool WarnOnMissingFiles { get; set; }

private LinkMethod MethodEnum { get; set; }

public override bool Execute()
Expand All @@ -37,6 +39,7 @@ public override bool Execute()
{
Method = MethodEnum,
SkipVerify = SkipVerify,
SkipWarningOnMissingFiles = !WarnOnMissingFiles,
GitRemoteUrl = GitRemoteUrl != null ? new Uri(GitRemoteUrl, UriKind.Absolute) : null,
CommitId = GitCommitId,
GitWorkingDirectory = GitWorkingDirectory,
Expand Down

0 comments on commit b5af8e8

Please sign in to comment.