Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Support --targetBranch for Azure Devops Server/TFS for remote repositories #1074

Merged
merged 4 commits into from
Nov 22, 2020
Merged
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
6 changes: 3 additions & 3 deletions NuKeeper.AzureDevOps/TfsSettingsReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public override async Task<RepositorySettings> RepositorySettings(Uri repository

var settings = repositoryUri.IsFile
? await CreateSettingsFromLocal(repositoryUri, targetBranch)
: CreateSettingsFromRemote(repositoryUri);
: CreateSettingsFromRemote(repositoryUri, targetBranch);
if (settings == null)
{
throw new NuKeeperException($"The provided uri was is not in the correct format. Provided {repositoryUri.ToString()} and format should be {UrlPattern}");
Expand All @@ -64,9 +64,9 @@ public override async Task<RepositorySettings> RepositorySettings(Uri repository
return settings;
}

private static RepositorySettings CreateSettingsFromRemote(Uri repositoryUri)
private static RepositorySettings CreateSettingsFromRemote(Uri repositoryUri, string targetBranch)
{
return RepositorySettings(repositoryUri);
return RepositorySettings(repositoryUri, new RemoteInfo { BranchName = targetBranch });
}

private async Task<RepositorySettings> CreateSettingsFromLocal(Uri repositoryUri, string targetBranch)
Expand Down
2 changes: 1 addition & 1 deletion NuKeeper/Commands/RepositoryCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public RepositoryCommand(ICollaborationEngine engine, IConfigureLogger logger, I
public string RepositoryUri { get; set; }

[Option(CommandOptionType.SingleValue, LongName = "targetBranch",
Description = "If the target branch is another branch than that you are currently on, set this to the target")]
Description = "Use another target branch than the currently active HEAD branch of the remote or local repository")]
public string TargetBranch { get; set; }

[Option(CommandOptionType.SingleValue, ShortName = "cdir", Description = "If you want NuKeeper to check out the repository to an alternate path, set it here (by default, a temporary directory is used).")]
Expand Down
14 changes: 12 additions & 2 deletions Nukeeper.AzureDevOps.Tests/TfsSettingsReaderTests.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System;
using System.Threading.Tasks;
using NSubstitute;
using NuKeeper.Abstractions;
using NuKeeper.Abstractions.CollaborationPlatform;
using NuKeeper.Abstractions.Configuration;
using NuKeeper.AzureDevOps;
using NuKeeper.Tests;
using NUnit.Framework;
using System;
using System.Threading.Tasks;

namespace Nukeeper.AzureDevOps.Tests
{
Expand Down Expand Up @@ -120,5 +120,15 @@ public async Task RepositorySettings_HandlesSpaces()
Assert.AreEqual("project name", settings.RepositoryOwner);
}

[Test]
public async Task RepositorySettings_WithRemoteUrlAndTargetBranch_ReturnsRemoteInfoWithSpecifiedBranchName()
{
var uri = new Uri("https://internalserver/tfs/project%20name/_git/repo%20name");
var targetBranch = "myTargetBranch";

var settings = await _azureSettingsReader.RepositorySettings(uri, false, targetBranch);

Assert.AreEqual("myTargetBranch", settings.RemoteInfo.BranchName);
}
}
}
2 changes: 1 addition & 1 deletion site/content/commands/repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ This is only available for azure devops and vsts
### Using a targetBranch

{{% notice info %}}
This is only available for azure devops, vsts and github right now
This is only available for azure devops, azure devops server, vsts, tfs, and github right now
{{% /notice %}}

In some cases you want NuKeeper not to run on the default branch but on a specific (feature-)branch
Expand Down