Commit 5584700389de5efdded8438451469f5557cac551

Authored by Diego Camarinha
Committed by Paulo Meireles
1 parent 68ded4d7

[Mezuro] Finished repository validation.

plugins/mezuro/public/javascripts/validations.js
@@ -8,7 +8,6 @@ function validate_code(code){ @@ -8,7 +8,6 @@ function validate_code(code){
8 return true; 8 return true;
9 } 9 }
10 10
11 -  
12 function validate_new_repository() { 11 function validate_new_repository() {
13 if (allRequiredFieldsAreFilled())) 12 if (allRequiredFieldsAreFilled()))
14 return addressAndTypeMatch(); 13 return addressAndTypeMatch();
@@ -31,7 +30,7 @@ function addressAndTypeMatch() { @@ -31,7 +30,7 @@ function addressAndTypeMatch() {
31 var address = jQuery('#repository_address').val(); 30 var address = jQuery('#repository_address').val();
32 31
33 switch (type) { 32 switch (type) {
34 - case "BAZAAR": return matchBAZAAR(address); 33 + case "BAZAAR": return matchBazaar(address);
35 case "CVS": return matchCVS(address); 34 case "CVS": return matchCVS(address);
36 case "GIT": return matchGIT(address); 35 case "GIT": return matchGIT(address);
37 case "MERCURIAL": return matchMercurial(address); 36 case "MERCURIAL": return matchMercurial(address);
@@ -41,17 +40,52 @@ function addressAndTypeMatch() { @@ -41,17 +40,52 @@ function addressAndTypeMatch() {
41 } 40 }
42 } 41 }
43 42
  43 +function matchBazaar(address) {
  44 + if (address.match(/bzr/))
  45 + return true;
  46 + alert("Address does not match type BAZAAR chosen.");
  47 + return false;
  48 +}
  49 +
  50 +function matchCVS(address) {
  51 + if (address.match(/cvs/))
  52 + return true;
  53 + alert("Address does not match type CVS chosen.");
  54 + return false;
  55 +}
  56 +
44 function matchGIT(address) { 57 function matchGIT(address) {
45 - if (address.match(/^[ http(s)?:\/\/git(hub)?\. | git:\/\/git(hub.com | orious.org)\/ | git@git(hub.com | orious.org):].+.git$/)) 58 + if (address.match(/^(http(s)?:\/\/git(hub)?\.|git:\/\/git(hub\.com|orious\.org)\/|git@git(hub\.com|orious\.org):).+.git$/))
  59 + return true;
  60 + alert("Address does not match type GIT chosen.");
  61 + return false;
  62 +}
  63 +
  64 +function matchMercurial(address) {
  65 + if (address.match(/^(http(s)?|ssh):\/\/.*hg/))
  66 + return true;
  67 + alert("Address does not match type MERCURIAL chosen.");
  68 + return false;
  69 +}
  70 +
  71 +function matchRemoteTarball(address) {
  72 + if (address.match(/\.tar(\..+)*$/))
  73 + return true;
  74 + alert("Address does not match type REMOTE_TARBALL chosen.");
  75 + return false;
  76 +}
  77 +
  78 +function matchRemoteZIP(address) {
  79 + if (address.match(/\.zip$/))
46 return true; 80 return true;
47 - alert("Adress does not match type GIT chosen."); 81 + alert("Address does not match type REMOTE_ZIP chosen.");
48 return false; 82 return false;
49 } 83 }
50 84
51 function matchSubversion(address) { 85 function matchSubversion(address) {
52 if (address.match(/^http(s)?:\/\/.+\/svn.+$/)) 86 if (address.match(/^http(s)?:\/\/.+\/svn.+$/))
53 return true; 87 return true;
54 - alert("Adress does not match type Subversion chosen."); 88 + alert("Address does not match type SUBVERSION chosen.");
55 return false; 89 return false;
56 } 90 }
57 91