Skip to content

Commit d5a7d04

Browse files
authored
Merge pull request #205 from mreishman/3.4.1
3.4.1
2 parents 83f5e12 + ce5514a commit d5a7d04

File tree

10 files changed

+271
-43
lines changed

10 files changed

+271
-43
lines changed

core/html/changelog.html

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,42 @@
11
<ul>
2+
<li>
3+
Version 3.4.1
4+
<ul>
5+
<li>
6+
Features
7+
<ul>
8+
<li>
9+
Added extra verification to git requests (commit, commit history, branch diff) for poll type version 2
10+
</li>
11+
</ul>
12+
</li>
13+
<li>
14+
Bug Fixes
15+
<ul>
16+
<li>
17+
Fixed style issue with git diff in info tab
18+
</li>
19+
<li>
20+
Added missing info to sidebar panel
21+
<ul>
22+
<li>
23+
Added missing current branch in branch history section of info tab
24+
</li>
25+
<li>
26+
Node name now shows up in info section of info tab
27+
</li>
28+
</ul>
29+
</li>
30+
<li>
31+
Fixed date issue in commit history tab
32+
</li>
33+
<li>
34+
Added poll type 1 block to all git requests (commit, commit history, branch diff)
35+
</li>
36+
</ul>
37+
</li>
38+
</ul>
39+
</li>
240
<li>
341
Version 3.4
442
<ul>

core/js/main.js

Lines changed: 58 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ function tryHttpActuallyPollLogic(count, name)
299299
{
300300
githubRepo = arrayOfFiles[count]["githubRepo"];
301301
}
302-
var data = {location: folder, name, githubRepo, urlForSend ,websiteBase: arrayOfFiles[count]["WebsiteBase"], id: arrayOfFiles[count]["Name"],branchList};
302+
var data = {pollType, location: folder, name, githubRepo, urlForSend ,websiteBase: arrayOfFiles[count]["WebsiteBase"], id: arrayOfFiles[count]["Name"],branchList};
303303
var innerData = {};
304304
if(pollType == "1")
305305
{
@@ -327,7 +327,7 @@ function tryHTTPSForPollRequest(_data)
327327
{
328328
var urlForSend = _data.urlForSend;
329329
urlForSend = urlForSend.replace("http","https");
330-
var data = {location: _data.location, name: _data.name, githubRepo: _data.githubRepo, websiteBase: _data.websiteBase, id: _data.id, branchList: _data.branchList};
330+
var data = {pollType, location: _data.location, name: _data.name, githubRepo: _data.githubRepo, websiteBase: _data.websiteBase, id: _data.id, branchList: _data.branchList};
331331
var innerData = {};
332332
if(pollType == "1")
333333
{
@@ -668,12 +668,26 @@ function pollSuccess(dataInner, dataInnerPass)
668668

669669
function generateBranchHistory(dataInner, repoName, baseRepoUrl)
670670
{
671-
if("branchHistoryList" in dataInner)
671+
if("branchHistoryList" in dataInner && dataInner["branchHistoryList"].length > 0)
672672
{
673-
var htmlToReturn = "<table style=\"word-break; break-all; width: 100%;\" ><tr><th width=\"50%\" ></th><th width=\"50%\" ></th></tr>";
673+
var htmlToReturn = "<table style=\"word-break; break-all; width: 100%;\" ><tr><th width=\"50%\" ></th><th width=\"50%\" ></th></tr><tr><td>";
674+
if(repoName !== "")
675+
{
676+
htmlToReturn += "<a style=\"color: black;\" target=\"_blank\" href=\"https://"+baseRepoUrl+"/"+repoName+"/tree/"+dataInner["branch"]+"\">";
677+
}
678+
htmlToReturn += dataInner["branch"];
679+
if(repoName !== "")
680+
{
681+
htmlToReturn += "</a>";
682+
}
683+
htmlToReturn += "</td><td>Current</td></tr>";
674684
var BHLlength = dataInner["branchHistoryList"].length;
675685
for(var BHLcount = 0; BHLcount < BHLlength; BHLcount++)
676686
{
687+
if(BHLcount === 0 && dataInner["branchHistoryList"][0]["name"] === dataInner["branch"])
688+
{
689+
continue;
690+
}
677691
htmlToReturn += "<tr><td>";
678692
if(repoName !== "")
679693
{
@@ -1749,6 +1763,7 @@ function getInfo()
17491763
return;
17501764
}
17511765
$("#infoBranchName").html($("#"+idName).html());
1766+
$("#nameMainLeft").html("<b>Name: </b>"+idName.split("branchNameDevBox1")[1]);
17521767
$("#infoMainLeft").html($("#innerFirstDevBox"+idName+" .devBoxContentSecondary").html());
17531768
$("#branchHistoryHolder").html($("#"+idName+"BranchHistory").html());
17541769
getDiffCommits();
@@ -1778,7 +1793,7 @@ function getDiffCommits()
17781793
{
17791794
branchList = arrayOfWatchFilters[idName]["branchList"];
17801795
}
1781-
var data = {location: arrayOfWatchFilters[idName]["location"], branchName, branchList};
1796+
var data = {pollType, location: arrayOfWatchFilters[idName]["location"], branchName, branchList};
17821797
(function(_data){
17831798
$.ajax({
17841799
url: urlForSend,
@@ -1819,7 +1834,7 @@ function getDiffCommitsHttp()
18191834
}
18201835
var branchList = defaultBranchList;
18211836

1822-
var data = {location: arrayOfWatchFilters[idName]["location"], branchName, branchList};
1837+
var data = {pollType, location: arrayOfWatchFilters[idName]["location"], branchName, branchList};
18231838
(function(_data){
18241839
$.ajax({
18251840
url: urlForSend,
@@ -1858,20 +1873,26 @@ function showDiffCommits(data)
18581873
}
18591874
data[currentBranchName] = {};
18601875
data[currentBranchName]["currentData"] = currentBranchStats;
1861-
data[currentBranchName]["commitDiff"] = currentBranchStats.split(/\D/);
1876+
if(currentBranchStats !== "Branch Not Found")
1877+
{
1878+
data[currentBranchName]["commitDiff"] = currentBranchStats.split(/\D/);
1879+
}
18621880
}
18631881
var baseForLeft = 0;
18641882
var baseForRight = 0;
18651883
for(var branchNameCount = 0; branchNameCount < dataKeysLength; branchNameCount++)
18661884
{
18671885
var currentBranchName = dataKeys[branchNameCount];
1868-
if(baseForLeft < data[currentBranchName]["commitDiff"][0])
1869-
{
1870-
baseForLeft = data[currentBranchName]["commitDiff"][0];
1871-
}
1872-
if(baseForRight < data[currentBranchName]["commitDiff"][1])
1886+
if("commitDiff" in data[currentBranchName])
18731887
{
1874-
baseForLeft = data[currentBranchName]["commitDiff"][1];
1888+
if(baseForLeft < data[currentBranchName]["commitDiff"][0])
1889+
{
1890+
baseForLeft = data[currentBranchName]["commitDiff"][0];
1891+
}
1892+
if(baseForRight < data[currentBranchName]["commitDiff"][1])
1893+
{
1894+
baseForLeft = data[currentBranchName]["commitDiff"][1];
1895+
}
18751896
}
18761897
}
18771898
if(baseForLeft == 0)
@@ -1895,10 +1916,26 @@ function showDiffCommits(data)
18951916
var row = table.insertRow(newRow);
18961917
var cell1 = row.insertCell(0);
18971918
var cell2 = row.insertCell(1);
1919+
var cell3 = row.insertCell(2);
1920+
var cell4 = row.insertCell(3);
1921+
var cell5 = row.insertCell(4);
1922+
var cell6 = row.insertCell(5);
18981923
cell1.innerHTML = "Origin/"+currentBranchName;
1899-
var commitDiffLeft = data[currentBranchName]["commitDiff"][0];
1900-
var commitDiffRight = data[currentBranchName]["commitDiff"][1];
1901-
cell2.innerHTML = "- "+commitDiffLeft+"<meter min=\"0\" max=\"1.2\" value=\""+(commitDiffLeft/baseForLeft)+"\" class=\"meterCommit meterCommitLeft\" ></meter> | <meter min=\"0\" max=\"1.2\" value=\""+(commitDiffRight/baseForRight)+"\" class=\"meterCommit meterCommitRight\" ></meter> + "+commitDiffRight;
1924+
if("commitDiff" in data[currentBranchName])
1925+
{
1926+
var commitDiffLeft = data[currentBranchName]["commitDiff"][0];
1927+
var commitDiffRight = data[currentBranchName]["commitDiff"][1];
1928+
cell2.innerHTML = "- "+commitDiffLeft;
1929+
cell3.innerHTML = "<meter min=\"0\" max=\"1.2\" value=\""+(commitDiffLeft/baseForLeft)+"\" class=\"meterCommit meterCommitLeft\" ></meter>";
1930+
cell4.innerHTML = " | ";
1931+
cell5.innerHTML = "<meter min=\"0\" max=\"1.2\" value=\""+(commitDiffRight/baseForRight)+"\" class=\"meterCommit meterCommitRight\" ></meter>";
1932+
cell6.innerHTML = "+ "+commitDiffRight;
1933+
}
1934+
else
1935+
{
1936+
cell3.innerHTML = data[currentBranchName]["currentData"];
1937+
}
1938+
19021939
}
19031940
document.getElementById("gitDiffLoading").style.display = "none";
19041941
document.getElementById("tableForCommitHistory").style.display = "table";
@@ -1935,7 +1972,7 @@ function getListOfCommits()
19351972
urlForSend += "/status/core/php/functions/";
19361973
}
19371974
urlForSend += "gitCommitHistory.php";
1938-
var data = {location: arrayOfWatchFilters[idName]["location"], maxCount: maxCommits};
1975+
var data = {pollType, location: arrayOfWatchFilters[idName]["location"], maxCount: maxCommits};
19391976
(function(_data){
19401977
$.ajax({
19411978
url: urlForSend,
@@ -1970,7 +2007,7 @@ function getListOfCommitsHttp()
19702007
urlForSend += "/status/core/php/functions/";
19712008
}
19722009
urlForSend += "gitCommitHistory.php";
1973-
var data = {location: arrayOfWatchFilters[idName]["location"], maxCount: maxCommits};
2010+
var data = {pollType, location: arrayOfWatchFilters[idName]["location"], maxCount: maxCommits};
19742011
(function(_data){
19752012
$.ajax({
19762013
url: urlForSend,
@@ -2068,7 +2105,7 @@ function commitListSuccessInner(data)
20682105
{
20692106
var dataTmp = data[i].replace("Date:","").trim();
20702107
dataTmp = new Date(dataTmp);
2071-
htmlForCommits += "<span style=\"float:right;\" ><b>"+dataTmp.getMonth()+"/"+dataTmp.getDate()+"/"+dataTmp.getFullYear()+"</b></span>";
2108+
htmlForCommits += "<span style=\"float:right;\" ><b>"+(dataTmp.getMonth()+1)+"/"+dataTmp.getDate()+"/"+dataTmp.getFullYear()+"</b></span>";
20722109
htmlForCommits += "<br>";
20732110
}
20742111
else
@@ -2112,7 +2149,7 @@ function viewCommit(idForCommit)
21122149
urlForSend += "/status/core/php/functions/";
21132150
}
21142151
urlForSend += "gitShowCommitStuff.php";
2115-
var data = {location: arrayOfWatchFilters[idName]["location"], commit: idForCommit};
2152+
var data = {pollType, location: arrayOfWatchFilters[idName]["location"], commit: idForCommit};
21162153
(function(_data){
21172154
$.ajax({
21182155
url: urlForSend,
@@ -2146,7 +2183,7 @@ function viewCommitHttp(idForCommit)
21462183
urlForSend += "/status/core/php/functions/";
21472184
}
21482185
urlForSend += "gitShowCommitStuff.php";
2149-
var data = {location: arrayOfWatchFilters[idName]["location"], commit: idForCommit};
2186+
var data = {pollType, location: arrayOfWatchFilters[idName]["location"], commit: idForCommit};
21502187
(function(_data){
21512188
$.ajax({
21522189
url: urlForSend,

core/php/configStatic.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<?php
33

44
$configStatic = array(
5-
'version' => '3.4',
5+
'version' => '3.4.1',
66
'lastCheck' => '12-14-2018',
77
'newestVersion' => '3.3.4',
88
'versionList' => array(

core/php/functions/gitBranchName.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,20 @@ function getBranchStats($location)
180180
return substr($branchStats, 0, strpos($branchStats, "}"));
181181
}
182182

183+
$pollType = null;
184+
if(isset($_POST['pollType']))
185+
{
186+
$pollType = 1;
187+
if(2 === intval($_POST['pollType']))
188+
{
189+
$pollType = 2;
190+
}
191+
}
183192

184-
if((isset($_POST['location']) && isset($_POST['name']) && isset($_POST['websiteBase'])) && $disablePostRequestWithPostData === "false")
193+
194+
if($disablePostRequestWithPostData === "false" && ($pollType === 1 || ($pollType === null && isset($_POST['location']) && isset($_POST['name']) && isset($_POST['websiteBase']))))
185195
{
186-
//old version!!!! (prior to 2.0)
196+
//Poll Type 1
187197

188198
$postLocation = $_POST['location'];
189199
$postName = $_POST['name'];
@@ -233,7 +243,7 @@ function getBranchStats($location)
233243
$lastResult = json_decode($cachedStatusMainObject, true);
234244
}
235245

236-
//new version (2.0 or greater) or just checking
246+
//Poll Type 2 (or just check)
237247
$response = array(
238248
'isHere' => true,
239249
'info' => array()
@@ -339,9 +349,9 @@ function getBranchStats($location)
339349
}
340350
catch (Exception $e)
341351
{
342-
352+
343353
}
344-
354+
345355
}
346356
}
347357
else
Lines changed: 73 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,74 @@
11
<?php header('Access-Control-Allow-Origin: *');
2-
$location = $_POST['location'];
3-
$currentBranch = $_POST['branchName'];
2+
3+
require_once("../../../core/conf/config.php");
4+
require_once("../../../local/default/conf/config.php");
5+
require_once("../../../core/php/loadVars.php");
6+
7+
$location = (string)$_POST['location'];
8+
$branchListCompare = "master";
9+
if(isset($_POST['branchList']))
10+
{
11+
$branchListCompare = (string)$_POST['branchList'];
12+
}
13+
$pollType = null;
14+
if(isset($_POST['pollType']))
15+
{
16+
$pollType = 1;
17+
if(2 === intval($_POST['pollType']))
18+
{
19+
$pollType = 2;
20+
}
21+
}
22+
23+
//if poll type is set, and poll type is 2: you can verify that location is real location (check config). Also if poll type 1 is set to block, block it.
24+
25+
if($pollType === 2)
26+
{
27+
//verify
28+
$verified = false;
29+
foreach ($serverWatchList as $key => $value)
30+
{
31+
if($value["Folder"] === $location)
32+
{
33+
$verified = true;
34+
break;
35+
}
36+
}
37+
if(!$verified)
38+
{
39+
echo json_encode(array());
40+
die();
41+
}
42+
}
43+
else
44+
{
45+
//check if block
46+
if(!($disablePostRequestWithPostData === "false"))
47+
{
48+
echo json_encode(array());
49+
die();
50+
}
51+
}
52+
53+
//get branch name
54+
$function = "git --git-dir=".escapeshellarg($location).".git branch | grep \* | cut -d ' ' -f2";
55+
$currentBranch = trim(shell_exec($function));
56+
57+
$function = "git --git-dir=".escapeshellarg($location).".git branch";
58+
$branchList = trim(shell_exec($function));
59+
$branchList = explode("\n", $branchList);
60+
$newBranchList = array();
61+
foreach ($branchList as $branchName)
62+
{
63+
array_push($newBranchList, strtolower(trim($branchName)));
64+
}
65+
$branchList = $newBranchList;
466

567
$returnData = array();
668
$function = "git --git-dir=".escapeshellarg($location).".git fetch";
769
shell_exec($function);
870
$function = "git --git-dir=".escapeshellarg($location).".git rev-list --left-right --count origin/".escapeshellarg($currentBranch)."...".escapeshellarg($currentBranch);
971
$returnData["current"] = trim(shell_exec($function));
10-
$branchListCompare = $_POST['branchList'];
1172
if(strpos($branchListCompare, ",") === -1)
1273
{
1374
$branchListCompare = array($branchListCompare);
@@ -19,7 +80,14 @@
1980
foreach ($branchListCompare as $branchCompare)
2081
{
2182
$branchName = trim($branchCompare);
22-
$function = "git --git-dir=".escapeshellarg($location).".git rev-list --left-right --count origin/".escapeshellarg($branchName)."...".escapeshellarg($currentBranch);
23-
$returnData[$branchName] = trim(shell_exec($function));
83+
if(in_array(strtolower($branchName), $branchList))
84+
{
85+
$function = "git --git-dir=".escapeshellarg($location).".git rev-list --left-right --count origin/".escapeshellarg($branchName)."...".escapeshellarg($currentBranch);
86+
$returnData[$branchName] = trim(shell_exec($function));
87+
}
88+
else
89+
{
90+
$returnData[$branchName] = "Branch Not Found";
91+
}
2492
}
2593
echo json_encode($returnData);

0 commit comments

Comments
 (0)