From cb4de60c0e6aa9538eba1e170188ab0dc6a9c211 Mon Sep 17 00:00:00 2001 From: Xiaomin Wu Date: Tue, 20 Oct 2015 15:07:05 -0700 Subject: [PATCH] VSOHandler fallback to use raw remote url as repo url when session token is not available. --- .../ServiceHookHandlers/VSOHandler.cs | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Kudu.Services/ServiceHookHandlers/VSOHandler.cs b/Kudu.Services/ServiceHookHandlers/VSOHandler.cs index 48a7d2b7a..cc1d2e561 100644 --- a/Kudu.Services/ServiceHookHandlers/VSOHandler.cs +++ b/Kudu.Services/ServiceHookHandlers/VSOHandler.cs @@ -1,9 +1,7 @@ using System; -using System.Collections.Generic; using System.Globalization; using System.Web; using Kudu.Contracts.Settings; -using Kudu.Contracts.Tracing; using Kudu.Core.Deployment; using Kudu.Core.SourceControl; using Newtonsoft.Json.Linq; @@ -46,11 +44,19 @@ protected virtual GitDeploymentInfo GetDeploymentInfo(HttpRequestBase request, J // even it is empty password we need to explicitly say so (with colon). // without colon, LibGit2Sharp is not working Uri remoteUrl = new Uri(_settings.GetValue("RepoUrl")); - info.RepositoryUrl = string.Format(CultureInfo.InvariantCulture, "{0}://{1}:@{2}{3}", - remoteUrl.Scheme, - sessionToken.Value("token"), - remoteUrl.Authority, - remoteUrl.PathAndQuery); + if (sessionToken == null) + { + // if there is no session token, fallback to use raw remoteUrl from setting.xml + info.RepositoryUrl = remoteUrl.AbsoluteUri; + } + else + { + info.RepositoryUrl = string.Format(CultureInfo.InvariantCulture, "{0}://{1}:@{2}{3}", + remoteUrl.Scheme, + sessionToken.Value("token"), + remoteUrl.Authority, + remoteUrl.PathAndQuery); + } info.TargetChangeset = DeploymentManager.CreateTemporaryChangeSet( authorName: info.Deployer,