Skip to content

Commit

Permalink
Allow empty Virtual Directory (#480)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmat committed Nov 4, 2019
1 parent 80135fa commit afa9aa7
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 30 deletions.
Binary file added docs/TfsVirtualDirectory/AzureDevOpsServer.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions docs/TfsVirtualDirectory/README.md
@@ -0,0 +1,19 @@
# Virtual Directory

Any version of the server can be configured to use Virtual Directory. By default, Azure DevOps Server 2019 uses empty Virtual Directory (`VirtualDirectory="/"`) while previous versions of the server used `/tfs` as the default.

To find out the value of Virtual Directory for your server check the server configuration as follows:

## Azure DevOps Server 2019 or later

Open _Azure DevOps Server Administration Console_ from start menu and navigate to _Application Tier_. The Virtual Directory is displayed in _Application Tier Summary_ under _Public URL_. It's the part of the URL that follows the server domain ("/VirtualDir" in the example below):

![Azure DevOps Server](AzureDevOpsServer.png)

## Team Foundation Server 2018 or earlier

Open _Team Foundation Server Administration Console_ from start menu and navigate to _Application Tier_. The Virtual Directory is listed in the _Application Tier Summary_:

![Team Foundation Server](TeamFoundationServer.png)


Binary file added docs/TfsVirtualDirectory/TeamFoundationServer.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Expand Up @@ -28,30 +28,6 @@ public void EmptyHosts()
Assert.False(result);
}

[Fact]
public void UnspecifiedVirtualDirectory()
{
var engine = new MockEngine();

var task = new GetSourceLinkUrl()
{
BuildEngine = engine,
SourceRoot = new MockItem("/src/", KVP("RepositoryUrl", "http://tfs.com/tfs/zzz"), KVP("SourceControl", "git"), KVP("RevisionId", "0123456789abcdefABCDEF000000000000000000")),
Hosts = new[]
{
new MockItem("tfs.com", KVP("VirtualDirectory", ""))
}
};

bool result = task.Execute();

// ERROR : Item 'tfs.com' of item group 'SourceLinkAzureDevOpsServerGitHost' must specify metadata 'VirtualDirectory'
AssertEx.AssertEqualToleratingWhitespaceDifferences(
"ERROR : " + string.Format(CommonResources.ItemOfItemGroupMustSpecifyMetadata, "tfs.com", "SourceLinkAzureDevOpsServerGitHost", "VirtualDirectory"), engine.Log);

Assert.False(result);
}

[Fact]
public void BadUrl()
{
Expand Down Expand Up @@ -150,6 +126,7 @@ public void BuildSourceLinkUrl(string s1, string s2)
}

[Theory]
[InlineData("", "/")]
[InlineData("/", "/")]
[InlineData("a", "/a/")]
[InlineData("a/", "/a/")]
Expand Down
6 changes: 0 additions & 6 deletions src/SourceLink.AzureDevOpsServer.Git/GetSourceLinkUrl.cs
Expand Up @@ -22,12 +22,6 @@ public sealed class GetSourceLinkUrl : GetSourceLinkUrlGitTask
protected override string BuildSourceLinkUrl(Uri contentUri, Uri gitUri, string relativeUrl, string revisionId, ITaskItem hostItem)
{
var virtualDirectory = hostItem.GetMetadata(VirtualDirectoryMetadataName);
if (string.IsNullOrEmpty(virtualDirectory))
{
Log.LogError(CommonResources.ItemOfItemGroupMustSpecifyMetadata, hostItem.ItemSpec, HostsItemGroupName, VirtualDirectoryMetadataName);
return null;
}

if (!AzureDevOpsUrlParser.TryParseOnPremHttp(relativeUrl, virtualDirectory, out var projectPath, out var repositoryName))
{
Log.LogError(CommonResources.ValueOfWithIdentityIsInvalid, Names.SourceRoot.RepositoryUrlFullName, SourceRoot.ItemSpec, gitUri);
Expand Down

0 comments on commit afa9aa7

Please sign in to comment.