Permalink
Browse files

#411: azure site create --github does not automatically choose correc…

…t remote when azure remote present
  • Loading branch information...
1 parent 791d1b4 commit 9c5ccf5d309b2ec71e1adf25da574868379f1885 Andre Rodrigues committed Oct 29, 2012
Showing with 30 additions and 22 deletions.
  1. +23 −19 lib/cli/linkedrevisioncontrol.js
  2. +7 −3 lib/cli/linkedrevisioncontrol_.js
@@ -65,16 +65,20 @@ LinkedRevisionControlClient._getRepository = function(repositories, remoteFullNa
LinkedRevisionControlClient._getRepositoryCloneUrl = function(repositories, remoteUri) {
return repositories.filter(function(repository) {
- return (((repository.clone_url.toLowerCase() === remoteUri.toLowerCase()) || (repository.html_url.toLowerCase() === remoteUri.toLowerCase())) || (repository.git_url.toLowerCase() === remoteUri.toLowerCase()));
+ return repositoryMatchUri(repository, remoteUri);
+ })[0];};
+
+
+function repositoryMatchUri(repository, remoteUri) {
+ return (((repository.clone_url.toLowerCase() === remoteUri.toLowerCase()) || (repository.html_url.toLowerCase() === remoteUri.toLowerCase())) || (repository.git_url.toLowerCase() === remoteUri.toLowerCase()));};
- })[0];};
-LinkedRevisionControlClient.prototype.determineIfCurrentDirectoryIsGitWorkingTree = function LinkedRevisionControlClient_prototype_determineIfCurrentDirectoryIsGitWorkingTree__1(context, _) { var isInsideWorkTree, lines, __this = this; var __frame = { name: "LinkedRevisionControlClient_prototype_determineIfCurrentDirectoryIsGitWorkingTree__1", line: 77 }; return __func(_, this, arguments, LinkedRevisionControlClient_prototype_determineIfCurrentDirectoryIsGitWorkingTree__1, 1, __frame, function __$LinkedRevisionControlClient_prototype_determineIfCurrentDirectoryIsGitWorkingTree__1() {
+LinkedRevisionControlClient.prototype.determineIfCurrentDirectoryIsGitWorkingTree = function LinkedRevisionControlClient_prototype_determineIfCurrentDirectoryIsGitWorkingTree__1(context, _) { var isInsideWorkTree, lines, __this = this; var __frame = { name: "LinkedRevisionControlClient_prototype_determineIfCurrentDirectoryIsGitWorkingTree__1", line: 81 }; return __func(_, this, arguments, LinkedRevisionControlClient_prototype_determineIfCurrentDirectoryIsGitWorkingTree__1, 1, __frame, function __$LinkedRevisionControlClient_prototype_determineIfCurrentDirectoryIsGitWorkingTree__1() {
__this.log.silly("determineIfCurrentDirectoryIsGitWorkingTree"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$LinkedRevisionControlClient_prototype_determineIfCurrentDirectoryIsGitWorkingTree__1() {
@@ -95,7 +99,7 @@ LinkedRevisionControlClient.prototype.determineIfCurrentDirectoryIsGitWorkingTre
-LinkedRevisionControlClient.prototype.initGitOnCurrentDirectory = function LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2(context, scaffold, _) { var __this = this; var __frame = { name: "LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2", line: 98 }; return __func(_, this, arguments, LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2, 2, __frame, function __$LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2() {
+LinkedRevisionControlClient.prototype.initGitOnCurrentDirectory = function LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2(context, scaffold, _) { var __this = this; var __frame = { name: "LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2", line: 102 }; return __func(_, this, arguments, LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2, 2, __frame, function __$LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2() {
__this.log.silly("initGitOnCurrentDirectoryIfNeeded");
if (context.flags.isGitWorkingTree) { return _(null); } ;
@@ -127,12 +131,12 @@ function GitClient(cli) {
util.inherits(GitClient, LinkedRevisionControlClient);
-GitClient.prototype.init = function GitClient_prototype_init__3(context, _) { var __this = this; var __frame = { name: "GitClient_prototype_init__3", line: 130 }; return __func(_, this, arguments, GitClient_prototype_init__3, 1, __frame, function __$GitClient_prototype_init__3() {
+GitClient.prototype.init = function GitClient_prototype_init__3(context, _) { var __this = this; var __frame = { name: "GitClient_prototype_init__3", line: 134 }; return __func(_, this, arguments, GitClient_prototype_init__3, 1, __frame, function __$GitClient_prototype_init__3() {
return __this.determineIfCurrentDirectoryIsGitWorkingTree(context, __cb(_, __frame, 1, 2, function __$GitClient_prototype_init__3() {
return __this.initGitOnCurrentDirectory(context, true, __cb(_, __frame, 2, 2, _, true)); }, true)); });};
-GitClient.prototype.deploy = function GitClient_prototype_deploy__4(context, _) { var __frame = { name: "GitClient_prototype_deploy__4", line: 135 }; return __func(_, this, arguments, GitClient_prototype_deploy__4, 1, __frame, _);};
+GitClient.prototype.deploy = function GitClient_prototype_deploy__4(context, _) { var __frame = { name: "GitClient_prototype_deploy__4", line: 139 }; return __func(_, this, arguments, GitClient_prototype_deploy__4, 1, __frame, _);};
@@ -144,7 +148,7 @@ function GithubClient(cli) {
util.inherits(GithubClient, LinkedRevisionControlClient);
-GithubClient.prototype.authenticate = function GithubClient_prototype_authenticate__5(context, _) { var __this = this; var __frame = { name: "GithubClient_prototype_authenticate__5", line: 147 }; return __func(_, this, arguments, GithubClient_prototype_authenticate__5, 1, __frame, function __$GithubClient_prototype_authenticate__5() {
+GithubClient.prototype.authenticate = function GithubClient_prototype_authenticate__5(context, _) { var __this = this; var __frame = { name: "GithubClient_prototype_authenticate__5", line: 151 }; return __func(_, this, arguments, GithubClient_prototype_authenticate__5, 1, __frame, function __$GithubClient_prototype_authenticate__5() {
return __this.ensureCredentials(context, __cb(_, __frame, 1, 2, function __$GithubClient_prototype_authenticate__5() {
__this.client.authenticate({
@@ -154,7 +158,7 @@ GithubClient.prototype.authenticate = function GithubClient_prototype_authentica
-GithubClient.prototype.authenticateAuth = function GithubClient_prototype_authenticateAuth__6(context, _) { var oauthToken, __this = this; var __frame = { name: "GithubClient_prototype_authenticateAuth__6", line: 157 }; return __func(_, this, arguments, GithubClient_prototype_authenticateAuth__6, 1, __frame, function __$GithubClient_prototype_authenticateAuth__6() {
+GithubClient.prototype.authenticateAuth = function GithubClient_prototype_authenticateAuth__6(context, _) { var oauthToken, __this = this; var __frame = { name: "GithubClient_prototype_authenticateAuth__6", line: 161 }; return __func(_, this, arguments, GithubClient_prototype_authenticateAuth__6, 1, __frame, function __$GithubClient_prototype_authenticateAuth__6() {
return __this.ensureCredentials(context, __cb(_, __frame, 1, 2, function __$GithubClient_prototype_authenticateAuth__6() {
__this.client.authenticate({
@@ -171,7 +175,7 @@ GithubClient.prototype.authenticateAuth = function GithubClient_prototype_authen
-GithubClient.prototype.ensureCredentials = function GithubClient_prototype_ensureCredentials__7(context, _) { var __this = this; var __frame = { name: "GithubClient_prototype_ensureCredentials__7", line: 174 }; return __func(_, this, arguments, GithubClient_prototype_ensureCredentials__7, 1, __frame, function __$GithubClient_prototype_ensureCredentials__7() {
+GithubClient.prototype.ensureCredentials = function GithubClient_prototype_ensureCredentials__7(context, _) { var __this = this; var __frame = { name: "GithubClient_prototype_ensureCredentials__7", line: 178 }; return __func(_, this, arguments, GithubClient_prototype_ensureCredentials__7, 1, __frame, function __$GithubClient_prototype_ensureCredentials__7() {
if (!context.github) {
context.github = { }; } ;
@@ -189,7 +193,7 @@ GithubClient.prototype.ensureCredentials = function GithubClient_prototype_ensur
-GithubClient.prototype.init = function GithubClient_prototype_init__8(context, _) { var repositories, remoteUris, __this = this; var __frame = { name: "GithubClient_prototype_init__8", line: 192 }; return __func(_, this, arguments, GithubClient_prototype_init__8, 1, __frame, function __$GithubClient_prototype_init__8() {
+GithubClient.prototype.init = function GithubClient_prototype_init__8(context, _) { var repositories, remoteUris, __this = this; var __frame = { name: "GithubClient_prototype_init__8", line: 196 }; return __func(_, this, arguments, GithubClient_prototype_init__8, 1, __frame, function __$GithubClient_prototype_init__8() {
return __this.authenticate(context, __cb(_, __frame, 1, 2, function __$GithubClient_prototype_init__8() {
@@ -217,7 +221,7 @@ GithubClient.prototype.init = function GithubClient_prototype_init__8(context, _
repositories = repositories.filter(function(repository) {
return remoteUris.some(function(remoteUri) {
- return (remoteUri === repository.clone_url); }); }); } ; } ; __then(); }, true)); } else { __then(); } ; })(__then); } ; })(function __$GithubClient_prototype_init__8() { return (function __$GithubClient_prototype_init__8(__then) {
+ return repositoryMatchUri(repository, remoteUri); }); }); } ; } ; __then(); }, true)); } else { __then(); } ; })(__then); } ; })(function __$GithubClient_prototype_init__8() { return (function __$GithubClient_prototype_init__8(__then) {
@@ -232,7 +236,7 @@ GithubClient.prototype.init = function GithubClient_prototype_init__8(context, _
-GithubClient.prototype.deploy = function GithubClient_prototype_deploy__9(context, _) { var __frame = { name: "GithubClient_prototype_deploy__9", line: 235 }; return __func(_, this, arguments, GithubClient_prototype_deploy__9, 1, __frame, function __$GithubClient_prototype_deploy__9() {
+GithubClient.prototype.deploy = function GithubClient_prototype_deploy__9(context, _) { var __frame = { name: "GithubClient_prototype_deploy__9", line: 239 }; return __func(_, this, arguments, GithubClient_prototype_deploy__9, 1, __frame, function __$GithubClient_prototype_deploy__9() {
return context.lvcClient.createOrUpdateHook(context.github.repository.owner.login, context.github.repository.name, context.repositoryUri, context.repositoryAuth, __cb(_, __frame, 2, 2, _, true)); });};
@@ -251,7 +255,7 @@ GithubClient.prototype.getRepositories = function GithubClient_prototype_getRepo
function filterPrivate(repository) {
- return (repository["private"] !== true); }; var __frame = { name: "GithubClient_prototype_getRepositories__10", line: 244 }; return __func(_, this, arguments, GithubClient_prototype_getRepositories__10, 1, __frame, function __$GithubClient_prototype_getRepositories__10() { progress = __this.cli.progress("Retrieving repositories"); userRepos = []; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$GithubClient_prototype_getRepositories__10() {
+ return (repository["private"] !== true); }; var __frame = { name: "GithubClient_prototype_getRepositories__10", line: 248 }; return __func(_, this, arguments, GithubClient_prototype_getRepositories__10, 1, __frame, function __$GithubClient_prototype_getRepositories__10() { progress = __this.cli.progress("Retrieving repositories"); userRepos = []; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$GithubClient_prototype_getRepositories__10() {
@@ -283,7 +287,7 @@ GithubClient.prototype.getRepositories = function GithubClient_prototype_getRepo
return _(null, userRepos); }); }); });};
-GithubClient.prototype.createOrUpdateHook = function GithubClient_prototype_createOrUpdateHook__11(username, repository, websitesRepositoryUri, websitesRepositoryAuth, _) { var parsedRepositoryUri, deployUri, hooks, existingHook, newHook, __this = this; var __frame = { name: "GithubClient_prototype_createOrUpdateHook__11", line: 286 }; return __func(_, this, arguments, GithubClient_prototype_createOrUpdateHook__11, 4, __frame, function __$GithubClient_prototype_createOrUpdateHook__11() {
+GithubClient.prototype.createOrUpdateHook = function GithubClient_prototype_createOrUpdateHook__11(username, repository, websitesRepositoryUri, websitesRepositoryAuth, _) { var parsedRepositoryUri, deployUri, hooks, existingHook, newHook, __this = this; var __frame = { name: "GithubClient_prototype_createOrUpdateHook__11", line: 290 }; return __func(_, this, arguments, GithubClient_prototype_createOrUpdateHook__11, 4, __frame, function __$GithubClient_prototype_createOrUpdateHook__11() {
parsedRepositoryUri = url.parse(websitesRepositoryUri);
parsedRepositoryUri.auth = websitesRepositoryAuth;
@@ -340,7 +344,7 @@ GithubClient.prototype.createOrUpdateHook = function GithubClient_prototype_crea
-GithubClient.prototype.createHook = function GithubClient_prototype_createHook__12(hook, _) { var progress, __this = this; var __frame = { name: "GithubClient_prototype_createHook__12", line: 343 }; return __func(_, this, arguments, GithubClient_prototype_createHook__12, 1, __frame, function __$GithubClient_prototype_createHook__12() {
+GithubClient.prototype.createHook = function GithubClient_prototype_createHook__12(hook, _) { var progress, __this = this; var __frame = { name: "GithubClient_prototype_createHook__12", line: 347 }; return __func(_, this, arguments, GithubClient_prototype_createHook__12, 1, __frame, function __$GithubClient_prototype_createHook__12() {
progress = __this.cli.progress("Creating new hook"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$GithubClient_prototype_createHook__12() {
@@ -350,7 +354,7 @@ GithubClient.prototype.createHook = function GithubClient_prototype_createHook__
-GithubClient.prototype.updateHook = function GithubClient_prototype_updateHook__13(hook, _) { var progress, __this = this; var __frame = { name: "GithubClient_prototype_updateHook__13", line: 353 }; return __func(_, this, arguments, GithubClient_prototype_updateHook__13, 1, __frame, function __$GithubClient_prototype_updateHook__13() {
+GithubClient.prototype.updateHook = function GithubClient_prototype_updateHook__13(hook, _) { var progress, __this = this; var __frame = { name: "GithubClient_prototype_updateHook__13", line: 357 }; return __func(_, this, arguments, GithubClient_prototype_updateHook__13, 1, __frame, function __$GithubClient_prototype_updateHook__13() {
progress = __this.cli.progress("Updating hook"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$GithubClient_prototype_updateHook__13() {
@@ -360,7 +364,7 @@ GithubClient.prototype.updateHook = function GithubClient_prototype_updateHook__
-GithubClient.prototype.testHook = function GithubClient_prototype_testHook__14(hook, _) { var progress, __this = this; var __frame = { name: "GithubClient_prototype_testHook__14", line: 363 }; return __func(_, this, arguments, GithubClient_prototype_testHook__14, 1, __frame, function __$GithubClient_prototype_testHook__14() {
+GithubClient.prototype.testHook = function GithubClient_prototype_testHook__14(hook, _) { var progress, __this = this; var __frame = { name: "GithubClient_prototype_testHook__14", line: 367 }; return __func(_, this, arguments, GithubClient_prototype_testHook__14, 1, __frame, function __$GithubClient_prototype_testHook__14() {
progress = __this.cli.progress("Testing hook"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$GithubClient_prototype_testHook__14() {
@@ -370,7 +374,7 @@ GithubClient.prototype.testHook = function GithubClient_prototype_testHook__14(h
-GithubClient.prototype.getHooks = function GithubClient_prototype_getHooks__15(username, repository, _) { var progress, __this = this; var __frame = { name: "GithubClient_prototype_getHooks__15", line: 373 }; return __func(_, this, arguments, GithubClient_prototype_getHooks__15, 2, __frame, function __$GithubClient_prototype_getHooks__15() {
+GithubClient.prototype.getHooks = function GithubClient_prototype_getHooks__15(username, repository, _) { var progress, __this = this; var __frame = { name: "GithubClient_prototype_getHooks__15", line: 377 }; return __func(_, this, arguments, GithubClient_prototype_getHooks__15, 2, __frame, function __$GithubClient_prototype_getHooks__15() {
progress = __this.cli.progress("Retrieving website hooks"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$GithubClient_prototype_getHooks__15() {
@@ -383,7 +387,7 @@ GithubClient.prototype.getHooks = function GithubClient_prototype_getHooks__15(u
-GithubClient.prototype._getRemoteUris = function GithubClient_prototype__getRemoteUris__16(_) { var progress, remoteUris, remotes, __this = this; var __frame = { name: "GithubClient_prototype__getRemoteUris__16", line: 386 }; return __func(_, this, arguments, GithubClient_prototype__getRemoteUris__16, 0, __frame, function __$GithubClient_prototype__getRemoteUris__16() {
+GithubClient.prototype._getRemoteUris = function GithubClient_prototype__getRemoteUris__16(_) { var progress, remoteUris, remotes, __this = this; var __frame = { name: "GithubClient_prototype__getRemoteUris__16", line: 390 }; return __func(_, this, arguments, GithubClient_prototype__getRemoteUris__16, 0, __frame, function __$GithubClient_prototype__getRemoteUris__16() {
progress = __this.cli.progress("Retrieving local git repositories");
remoteUris = []; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$GithubClient_prototype__getRemoteUris__16() {
@@ -65,11 +65,15 @@ LinkedRevisionControlClient._getRepository = function (repositories, remoteFullN
*/
LinkedRevisionControlClient._getRepositoryCloneUrl = function (repositories, remoteUri) {
return repositories.filter(function (repository) {
+ return repositoryMatchUri(repository, remoteUri);
+ })[0];
+};
+
+function repositoryMatchUri (repository, remoteUri) {
return repository.clone_url.toLowerCase() === remoteUri.toLowerCase()
|| repository.html_url.toLowerCase() === remoteUri.toLowerCase()
|| repository.git_url.toLowerCase() === remoteUri.toLowerCase();
- })[0];
-};
+}
/**
* Determines if the current directory is within a git repository tree.
@@ -217,7 +221,7 @@ GithubClient.prototype.init = function (context, _) {
// filter repositories to reduce prompt options
repositories = repositories.filter(function (repository) {
return remoteUris.some(function (remoteUri) {
- return remoteUri === repository.clone_url;
+ return repositoryMatchUri(repository, remoteUri);
});
});
}

0 comments on commit 9c5ccf5

Please sign in to comment.