Skip to content

Commit

Permalink
change making dropbox author and email to be part of payload, not per…
Browse files Browse the repository at this point in the history
…sisted
  • Loading branch information
suwatch committed Jan 14, 2013
1 parent b907f8e commit da074f7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 25 deletions.
4 changes: 4 additions & 0 deletions Kudu.Contracts/Dropbox/DropboxDeployInfo.cs
Expand Up @@ -21,6 +21,10 @@ public class DropboxDeployInfo


public string Path { get; set; } public string Path { get; set; }


public string UserName { get; set; }

public string Email { get; set; }

public IEnumerable<DropboxDeltaInfo> Deltas { get; set; } public IEnumerable<DropboxDeltaInfo> Deltas { get; set; }
} }
} }
11 changes: 4 additions & 7 deletions Kudu.FunctionalTests/DropboxTests.cs
Expand Up @@ -35,16 +35,11 @@ public void TestDropboxBasic()
} }


AccountInfo account = GetAccountInfo(oauth); AccountInfo account = GetAccountInfo(oauth);
DropboxDeployInfo deploy = GetDeployInfo(oauth); DropboxDeployInfo deploy = GetDeployInfo(oauth, account);


string appName = KuduUtils.GetRandomWebsiteName("DropboxTest"); string appName = KuduUtils.GetRandomWebsiteName("DropboxTest");
ApplicationManager.Run(appName, appManager => ApplicationManager.Run(appName, appManager =>
{ {
appManager.SettingsManager.SetValues(
new KeyValuePair<string, string>("dropbox_username", account.display_name),
new KeyValuePair<string, string>("dropbox_email", account.email)
).Wait();
HttpClient client = HttpClientHelper.CreateClient(appManager.ServiceUrl, appManager.DeploymentManager.Credentials); HttpClient client = HttpClientHelper.CreateClient(appManager.ServiceUrl, appManager.DeploymentManager.Credentials);
client.PostAsJsonAsync("deploy", deploy).Result.EnsureSuccessful(); client.PostAsJsonAsync("deploy", deploy).Result.EnsureSuccessful();
Expand Down Expand Up @@ -98,7 +93,7 @@ private DeltaInfo GetDeltaInfo(OAuthInfo oauth, string cursor = null)
} }
} }


private DropboxDeployInfo GetDeployInfo(OAuthInfo oauth, string cursor = null) private DropboxDeployInfo GetDeployInfo(OAuthInfo oauth, AccountInfo account, string cursor = null)
{ {
List<DropboxDeltaInfo> deltas = new List<DropboxDeltaInfo>(); List<DropboxDeltaInfo> deltas = new List<DropboxDeltaInfo>();
string timeStamp = GetUtcTimeStamp(); string timeStamp = GetUtcTimeStamp();
Expand Down Expand Up @@ -155,6 +150,8 @@ private DropboxDeployInfo GetDeployInfo(OAuthInfo oauth, string cursor = null)
OldCursor = oldCursor, OldCursor = oldCursor,
NewCursor = newCursor, NewCursor = newCursor,
Path = "/", Path = "/",
UserName = account.display_name,
Email = account.email,
Deltas = deltas Deltas = deltas
}; };
} }
Expand Down
16 changes: 1 addition & 15 deletions Kudu.Services/FetchHelpers/DropboxHelper.cs
Expand Up @@ -19,8 +19,6 @@ public class DropboxHelper
{ {
public const string Dropbox = "dropbox"; public const string Dropbox = "dropbox";
public const string CursorKey = "dropbox_cursor"; public const string CursorKey = "dropbox_cursor";
public const string UserNameKey = "dropbox_username";
public const string EmailKey = "dropbox_email";


private const string DropboxApiContentUri = "https://api-content.dropbox.com/"; private const string DropboxApiContentUri = "https://api-content.dropbox.com/";
private const string SandboxFilePath = "1/files/sandbox"; private const string SandboxFilePath = "1/files/sandbox";
Expand Down Expand Up @@ -72,7 +70,7 @@ public ChangeSet Sync(DropboxDeployInfo info, string branch)
finally finally
{ {
// Commit anyway even partial change // Commit anyway even partial change
changeSet = _repository.Commit(prefix + " sync with dropbox at " + DateTime.UtcNow.ToString("g"), GetAuthor()); changeSet = _repository.Commit(prefix + " sync with dropbox at " + DateTime.UtcNow.ToString("g"), String.Format("{0} <{1}>", info.UserName, info.Email));
} }


// Save new dropboc cursor // Save new dropboc cursor
Expand All @@ -94,18 +92,6 @@ private bool IsEmptyRepo()
} }
} }


private string GetAuthor()
{
string userName = _settings.GetValue(UserNameKey);
string email = _settings.GetValue(EmailKey);
if (!String.IsNullOrEmpty(userName) && !String.IsNullOrEmpty(email))
{
return String.Format("{0} <{1}>", userName, email);
}

return null;
}

private void ApplyChanges(DropboxDeployInfo info) private void ApplyChanges(DropboxDeployInfo info)
{ {
Semaphore sem = new Semaphore(MaxConcurrentRequests, MaxConcurrentRequests); Semaphore sem = new Semaphore(MaxConcurrentRequests, MaxConcurrentRequests);
Expand Down
7 changes: 4 additions & 3 deletions Kudu.Services/ServiceHookHandlers/DropboxHandler.cs
Expand Up @@ -30,11 +30,12 @@ public DeployAction TryParseDeploymentInfo(HttpRequestBase request, JObject payl
deploymentInfo = null; deploymentInfo = null;
if (!String.IsNullOrEmpty(payload.Value<string>("NewCursor"))) if (!String.IsNullOrEmpty(payload.Value<string>("NewCursor")))
{ {
deploymentInfo = new DropboxInfo(payload); var dropboxInfo = new DropboxInfo(payload);
deploymentInfo = dropboxInfo;


// Temporary deployment // Temporary deployment
string authorName = _settings.GetValue(DropboxHelper.UserNameKey) ?? _settings.GetGitUsername(); string authorName = dropboxInfo.DeployInfo.UserName;
string authorEmail = _settings.GetValue(DropboxHelper.EmailKey) ?? _settings.GetGitEmail(); string authorEmail = dropboxInfo.DeployInfo.Email;
string message = "Syncing with dropbox at " + DateTime.UtcNow.ToString("g"); string message = "Syncing with dropbox at " + DateTime.UtcNow.ToString("g");
deploymentInfo.TargetChangeset = new ChangeSet("InProgress", authorName, authorEmail, message, DateTimeOffset.MinValue); deploymentInfo.TargetChangeset = new ChangeSet("InProgress", authorName, authorEmail, message, DateTimeOffset.MinValue);


Expand Down

0 comments on commit da074f7

Please sign in to comment.