mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-06 13:25:51 +01:00
bug fix: git manager
This commit is contained in:
@@ -5974,8 +5974,15 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var changeBranch = 0;
|
||||||
|
|
||||||
$scope.changeBranch = function () {
|
$scope.changeBranch = function () {
|
||||||
|
|
||||||
|
if(changeBranch === 1){
|
||||||
|
changeBranch = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
$scope.loadingSticks = false;
|
$scope.loadingSticks = false;
|
||||||
$("#showStatus").modal();
|
$("#showStatus").modal();
|
||||||
|
|
||||||
@@ -6038,6 +6045,7 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
|||||||
$scope.cyberpanelLoading = false;
|
$scope.cyberpanelLoading = false;
|
||||||
$scope.commandStatus = "";
|
$scope.commandStatus = "";
|
||||||
$scope.statusBox = false;
|
$scope.statusBox = false;
|
||||||
|
changeBranch = 1;
|
||||||
|
|
||||||
url = "/websites/createNewBranch";
|
url = "/websites/createNewBranch";
|
||||||
|
|
||||||
@@ -6531,11 +6539,13 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var currentComit;
|
var currentComit;
|
||||||
|
var fetchFileCheck = 0;
|
||||||
|
|
||||||
$scope.fetchFiles = function (commit) {
|
$scope.fetchFiles = function (commit) {
|
||||||
|
|
||||||
currentComit = commit;
|
currentComit = commit;
|
||||||
$scope.cyberpanelLoading = false;
|
$scope.cyberpanelLoading = false;
|
||||||
|
fetchFileCheck = 1;
|
||||||
|
|
||||||
url = "/websites/fetchFiles";
|
url = "/websites/fetchFiles";
|
||||||
|
|
||||||
@@ -6590,13 +6600,17 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
|||||||
$scope.fileStatus = true;
|
$scope.fileStatus = true;
|
||||||
|
|
||||||
$scope.fetchChangesInFile = function () {
|
$scope.fetchChangesInFile = function () {
|
||||||
|
$scope.fileStatus = true;
|
||||||
|
if(fetchFileCheck === 1){
|
||||||
|
fetchFileCheck = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
$scope.cyberpanelLoading = false;
|
$scope.cyberpanelLoading = false;
|
||||||
$scope.currentSelectedFile = $scope.changeFile;
|
$scope.currentSelectedFile = $scope.changeFile;
|
||||||
|
|
||||||
url = "/websites/fetchChangesInFile";
|
url = "/websites/fetchChangesInFile";
|
||||||
|
|
||||||
|
|
||||||
var data = {
|
var data = {
|
||||||
domain: $("#domain").text(),
|
domain: $("#domain").text(),
|
||||||
folder: $scope.folder,
|
folder: $scope.folder,
|
||||||
@@ -6623,14 +6637,13 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
|||||||
$scope.fileStatus = false;
|
$scope.fileStatus = false;
|
||||||
document.getElementById("fileChangedContent").innerHTML = response.data.fileChangedContent;
|
document.getElementById("fileChangedContent").innerHTML = response.data.fileChangedContent;
|
||||||
} else {
|
} else {
|
||||||
|
$scope.fileStatus = true;
|
||||||
new PNotify({
|
new PNotify({
|
||||||
title: 'Operation Failed!',
|
title: 'Operation Failed!',
|
||||||
text: response.data.error_message,
|
text: response.data.error_message,
|
||||||
type: 'error'
|
type: 'error'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function cantLoadInitialDatas(response) {
|
function cantLoadInitialDatas(response) {
|
||||||
|
|||||||
@@ -5974,8 +5974,15 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var changeBranch = 0;
|
||||||
|
|
||||||
$scope.changeBranch = function () {
|
$scope.changeBranch = function () {
|
||||||
|
|
||||||
|
if(changeBranch === 1){
|
||||||
|
changeBranch = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
$scope.loadingSticks = false;
|
$scope.loadingSticks = false;
|
||||||
$("#showStatus").modal();
|
$("#showStatus").modal();
|
||||||
|
|
||||||
@@ -6038,6 +6045,7 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
|||||||
$scope.cyberpanelLoading = false;
|
$scope.cyberpanelLoading = false;
|
||||||
$scope.commandStatus = "";
|
$scope.commandStatus = "";
|
||||||
$scope.statusBox = false;
|
$scope.statusBox = false;
|
||||||
|
changeBranch = 1;
|
||||||
|
|
||||||
url = "/websites/createNewBranch";
|
url = "/websites/createNewBranch";
|
||||||
|
|
||||||
@@ -6531,11 +6539,13 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var currentComit;
|
var currentComit;
|
||||||
|
var fetchFileCheck = 0;
|
||||||
|
|
||||||
$scope.fetchFiles = function (commit) {
|
$scope.fetchFiles = function (commit) {
|
||||||
|
|
||||||
currentComit = commit;
|
currentComit = commit;
|
||||||
$scope.cyberpanelLoading = false;
|
$scope.cyberpanelLoading = false;
|
||||||
|
fetchFileCheck = 1;
|
||||||
|
|
||||||
url = "/websites/fetchFiles";
|
url = "/websites/fetchFiles";
|
||||||
|
|
||||||
@@ -6590,13 +6600,17 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
|||||||
$scope.fileStatus = true;
|
$scope.fileStatus = true;
|
||||||
|
|
||||||
$scope.fetchChangesInFile = function () {
|
$scope.fetchChangesInFile = function () {
|
||||||
|
$scope.fileStatus = true;
|
||||||
|
if(fetchFileCheck === 1){
|
||||||
|
fetchFileCheck = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
$scope.cyberpanelLoading = false;
|
$scope.cyberpanelLoading = false;
|
||||||
$scope.currentSelectedFile = $scope.changeFile;
|
$scope.currentSelectedFile = $scope.changeFile;
|
||||||
|
|
||||||
url = "/websites/fetchChangesInFile";
|
url = "/websites/fetchChangesInFile";
|
||||||
|
|
||||||
|
|
||||||
var data = {
|
var data = {
|
||||||
domain: $("#domain").text(),
|
domain: $("#domain").text(),
|
||||||
folder: $scope.folder,
|
folder: $scope.folder,
|
||||||
@@ -6623,14 +6637,13 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
|||||||
$scope.fileStatus = false;
|
$scope.fileStatus = false;
|
||||||
document.getElementById("fileChangedContent").innerHTML = response.data.fileChangedContent;
|
document.getElementById("fileChangedContent").innerHTML = response.data.fileChangedContent;
|
||||||
} else {
|
} else {
|
||||||
|
$scope.fileStatus = true;
|
||||||
new PNotify({
|
new PNotify({
|
||||||
title: 'Operation Failed!',
|
title: 'Operation Failed!',
|
||||||
text: response.data.error_message,
|
text: response.data.error_message,
|
||||||
type: 'error'
|
type: 'error'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function cantLoadInitialDatas(response) {
|
function cantLoadInitialDatas(response) {
|
||||||
|
|||||||
@@ -674,8 +674,7 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-hide="fileStatus" class="example-box-wrapper">
|
<div ng-hide='fileStatus' class="row">
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="content-box">
|
<div class="content-box">
|
||||||
<table style="margin-top: 3%; margin-right: 0px; margin-left: 0px" class="table">
|
<table style="margin-top: 3%; margin-right: 0px; margin-left: 0px" class="table">
|
||||||
@@ -692,7 +691,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|||||||
@@ -2941,14 +2941,14 @@ StrictHostKeyChecking no
|
|||||||
if ProcessUtilities.outputExecutioner(command, self.externalApp).find('No such file or directory') > -1:
|
if ProcessUtilities.outputExecutioner(command, self.externalApp).find('No such file or directory') > -1:
|
||||||
|
|
||||||
command = 'cat /home/%s/.ssh/%s.pub' % (self.domain, website.externalApp)
|
command = 'cat /home/%s/.ssh/%s.pub' % (self.domain, website.externalApp)
|
||||||
deploymentKey = ProcessUtilities.outputExecutioner(command, website.externalApp)
|
deploymentKey = ProcessUtilities.outputExecutioner(command)
|
||||||
|
|
||||||
if deploymentKey.find('No such file or directory') > -1:
|
if deploymentKey.find('No such file or directory') > -1:
|
||||||
command = "ssh-keygen -f /home/%s/.ssh/%s -t rsa -N ''" % (self.domain, website.externalApp)
|
command = "ssh-keygen -f /home/%s/.ssh/%s -t rsa -N ''" % (self.domain, website.externalApp)
|
||||||
ProcessUtilities.executioner(command, website.externalApp)
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
command = 'cat /home/%s/.ssh/%s.pub' % (self.domain, website.externalApp)
|
command = 'cat /home/%s/.ssh/%s.pub' % (self.domain, website.externalApp)
|
||||||
deploymentKey = ProcessUtilities.outputExecutioner(command, website.externalApp)
|
deploymentKey = ProcessUtilities.outputExecutioner(command)
|
||||||
|
|
||||||
home = 0
|
home = 0
|
||||||
if self.folder == '/home/%s/public_html' % (self.domain):
|
if self.folder == '/home/%s/public_html' % (self.domain):
|
||||||
@@ -2962,24 +2962,24 @@ StrictHostKeyChecking no
|
|||||||
## Find git branches
|
## Find git branches
|
||||||
|
|
||||||
command = 'git -C %s branch' % (self.folder)
|
command = 'git -C %s branch' % (self.folder)
|
||||||
branches = ProcessUtilities.outputExecutioner(command, self.externalApp).split('\n')[:-1]
|
branches = ProcessUtilities.outputExecutioner(command).split('\n')[:-1]
|
||||||
|
|
||||||
## Fetch key
|
## Fetch key
|
||||||
|
|
||||||
command = 'cat /home/%s/.ssh/%s.pub' % (self.domain, website.externalApp)
|
command = 'cat /home/%s/.ssh/%s.pub' % (self.domain, website.externalApp)
|
||||||
deploymentKey = ProcessUtilities.outputExecutioner(command, website.externalApp)
|
deploymentKey = ProcessUtilities.outputExecutioner(command)
|
||||||
|
|
||||||
if deploymentKey.find('No such file or directory') > -1:
|
if deploymentKey.find('No such file or directory') > -1:
|
||||||
command = "ssh-keygen -f /home/%s/.ssh/%s -t rsa -N ''" % (self.domain, website.externalApp)
|
command = "ssh-keygen -f /home/%s/.ssh/%s -t rsa -N ''" % (self.domain, website.externalApp)
|
||||||
ProcessUtilities.executioner(command, website.externalApp)
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
command = 'cat /home/%s/.ssh/%s.pub' % (self.domain, website.externalApp)
|
command = 'cat /home/%s/.ssh/%s.pub' % (self.domain, website.externalApp)
|
||||||
deploymentKey = ProcessUtilities.outputExecutioner(command, website.externalApp)
|
deploymentKey = ProcessUtilities.outputExecutioner(command)
|
||||||
|
|
||||||
## Find Remote if any
|
## Find Remote if any
|
||||||
|
|
||||||
command = 'git -C %s remote -v' % (self.folder)
|
command = 'git -C %s remote -v' % (self.folder)
|
||||||
remoteResult = ProcessUtilities.outputExecutioner(command, self.externalApp)
|
remoteResult = ProcessUtilities.outputExecutioner(command )
|
||||||
|
|
||||||
remote = 1
|
remote = 1
|
||||||
if remoteResult.find('origin') == -1:
|
if remoteResult.find('origin') == -1:
|
||||||
@@ -2989,7 +2989,7 @@ StrictHostKeyChecking no
|
|||||||
## Find Total commits on current branch
|
## Find Total commits on current branch
|
||||||
|
|
||||||
command = 'git -C %s rev-list --count HEAD' % (self.folder)
|
command = 'git -C %s rev-list --count HEAD' % (self.folder)
|
||||||
totalCommits = ProcessUtilities.outputExecutioner(command, self.externalApp)
|
totalCommits = ProcessUtilities.outputExecutioner(command )
|
||||||
|
|
||||||
if totalCommits.find('fatal') > -1:
|
if totalCommits.find('fatal') > -1:
|
||||||
totalCommits = '0'
|
totalCommits = '0'
|
||||||
@@ -3029,10 +3029,20 @@ StrictHostKeyChecking no
|
|||||||
else:
|
else:
|
||||||
return ACLManager.loadErrorJson()
|
return ACLManager.loadErrorJson()
|
||||||
|
|
||||||
|
website = Websites.objects.get(domain=self.domain)
|
||||||
|
|
||||||
command = 'git -C %s init' % (self.folder)
|
command = 'git -C %s init' % (self.folder)
|
||||||
result = ProcessUtilities.outputExecutioner(command, self.externalApp)
|
result = ProcessUtilities.outputExecutioner(command )
|
||||||
|
|
||||||
if result.find('Initialized empty Git repository in') > -1:
|
if result.find('Initialized empty Git repository in') > -1:
|
||||||
|
|
||||||
|
command = 'git -C %s config --local user.email %s' % (self.folder, website.adminEmail)
|
||||||
|
ProcessUtilities.executioner(command )
|
||||||
|
|
||||||
|
command = 'git -C %s config --local user.name "%s %s"' % (
|
||||||
|
self.folder, website.admin.firstName, website.admin.lastName)
|
||||||
|
ProcessUtilities.executioner(command )
|
||||||
|
|
||||||
data_ret = {'status': 1}
|
data_ret = {'status': 1}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
@@ -3087,12 +3097,12 @@ StrictHostKeyChecking no
|
|||||||
else:
|
else:
|
||||||
command = 'git -C %s remote set-url origin git@%s:%s/%s.git' % (self.folder, self.gitHost, self.gitUsername, self.gitReponame)
|
command = 'git -C %s remote set-url origin git@%s:%s/%s.git' % (self.folder, self.gitHost, self.gitUsername, self.gitReponame)
|
||||||
|
|
||||||
possibleError = ProcessUtilities.outputExecutioner(command, self.externalApp)
|
possibleError = ProcessUtilities.outputExecutioner(command )
|
||||||
|
|
||||||
## Check if set correctly.
|
## Check if set correctly.
|
||||||
|
|
||||||
command = 'git -C %s remote -v' % (self.folder)
|
command = 'git -C %s remote -v' % (self.folder)
|
||||||
remoteResult = ProcessUtilities.outputExecutioner(command, self.externalApp)
|
remoteResult = ProcessUtilities.outputExecutioner(command )
|
||||||
|
|
||||||
if remoteResult.find(self.gitUsername) > -1:
|
if remoteResult.find(self.gitUsername) > -1:
|
||||||
data_ret = {'status': 1}
|
data_ret = {'status': 1}
|
||||||
@@ -3135,7 +3145,7 @@ StrictHostKeyChecking no
|
|||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
command = 'git -C %s checkout %s' % (self.folder, self.branchName.strip(' '))
|
command = 'git -C %s checkout %s' % (self.folder, self.branchName.strip(' '))
|
||||||
commandStatus = ProcessUtilities.outputExecutioner(command, self.externalApp)
|
commandStatus = ProcessUtilities.outputExecutioner(command )
|
||||||
|
|
||||||
if commandStatus.find('Switched to branch') > -1:
|
if commandStatus.find('Switched to branch') > -1:
|
||||||
data_ret = {'status': 1, 'commandStatus': commandStatus + 'Refreshing page in 3 seconds..'}
|
data_ret = {'status': 1, 'commandStatus': commandStatus + 'Refreshing page in 3 seconds..'}
|
||||||
@@ -3172,7 +3182,7 @@ StrictHostKeyChecking no
|
|||||||
return ACLManager.loadErrorJson()
|
return ACLManager.loadErrorJson()
|
||||||
|
|
||||||
command = 'git -C %s checkout -b "%s"' % (self.folder, self.newBranchName)
|
command = 'git -C %s checkout -b "%s"' % (self.folder, self.newBranchName)
|
||||||
commandStatus = ProcessUtilities.outputExecutioner(command, self.externalApp)
|
commandStatus = ProcessUtilities.outputExecutioner(command )
|
||||||
|
|
||||||
if commandStatus.find(self.newBranchName) > -1:
|
if commandStatus.find(self.newBranchName) > -1:
|
||||||
data_ret = {'status': 1, 'commandStatus': commandStatus}
|
data_ret = {'status': 1, 'commandStatus': commandStatus}
|
||||||
@@ -3211,10 +3221,10 @@ StrictHostKeyChecking no
|
|||||||
## Check if remote exists
|
## Check if remote exists
|
||||||
|
|
||||||
command = 'git -C %s add -A' % (self.folder)
|
command = 'git -C %s add -A' % (self.folder)
|
||||||
ProcessUtilities.outputExecutioner(command, self.externalApp)
|
ProcessUtilities.outputExecutioner(command )
|
||||||
|
|
||||||
command = 'git -C %s commit -m "%s"' % (self.folder, self.commitMessage)
|
command = 'git -C %s commit -m "%s"' % (self.folder, self.commitMessage)
|
||||||
commandStatus = ProcessUtilities.outputExecutioner(command, self.externalApp)
|
commandStatus = ProcessUtilities.outputExecutioner(command )
|
||||||
|
|
||||||
if commandStatus.find('nothing to commit') == -1:
|
if commandStatus.find('nothing to commit') == -1:
|
||||||
data_ret = {'status': 1, 'commandStatus': commandStatus}
|
data_ret = {'status': 1, 'commandStatus': commandStatus}
|
||||||
@@ -3254,9 +3264,9 @@ StrictHostKeyChecking no
|
|||||||
|
|
||||||
externalApp = Websites.objects.get(domain=self.domain).externalApp
|
externalApp = Websites.objects.get(domain=self.domain).externalApp
|
||||||
|
|
||||||
command = 'git -C %s config --local core.sshCommand "ssh -i /home/%s/.ssh/%s"' % (
|
command = 'git -C %s config --local core.sshCommand "ssh -i /home/%s/.ssh/%s -o "StrictHostKeyChecking=no""' % (
|
||||||
self.folder, self.domain, externalApp)
|
self.folder, self.domain, externalApp)
|
||||||
ProcessUtilities.executioner(command, self.externalApp)
|
ProcessUtilities.executioner(command )
|
||||||
|
|
||||||
## Check if remote exists
|
## Check if remote exists
|
||||||
|
|
||||||
@@ -3301,21 +3311,26 @@ StrictHostKeyChecking no
|
|||||||
|
|
||||||
externalApp = Websites.objects.get(domain=self.domain).externalApp
|
externalApp = Websites.objects.get(domain=self.domain).externalApp
|
||||||
|
|
||||||
command = 'git -C %s config --local core.sshCommand "ssh -i /home/%s/.ssh/%s"' % (
|
command = 'git -C %s config --local core.sshCommand "ssh -i /home/%s/.ssh/%s -o "StrictHostKeyChecking=no""' % (
|
||||||
self.folder, self.domain, externalApp)
|
self.folder, self.domain, externalApp)
|
||||||
ProcessUtilities.executioner(command, self.externalApp)
|
ProcessUtilities.executioner(command )
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
||||||
command = 'git -C %s push' % (self.folder)
|
command = 'git -C %s push' % (self.folder)
|
||||||
commandStatus = ProcessUtilities.outputExecutioner(command, self.externalApp)
|
commandStatus = ProcessUtilities.outputExecutioner(command )
|
||||||
|
|
||||||
if commandStatus.find('has no upstream branch') > -1:
|
if commandStatus.find('has no upstream branch') > -1:
|
||||||
command = 'git -C %s rev-parse --abbrev-ref HEAD' % (self.folder)
|
command = 'git -C %s rev-parse --abbrev-ref HEAD' % (self.folder)
|
||||||
currentBranch = ProcessUtilities.outputExecutioner(command, self.externalApp).rstrip('\n')
|
currentBranch = ProcessUtilities.outputExecutioner(command ).rstrip('\n')
|
||||||
|
|
||||||
|
if currentBranch.find('fatal: ambiguous argument') > -1:
|
||||||
|
data_ret = {'status': 0, 'error_message': 'You need to commit first.', 'commandStatus': 'You need to commit first.'}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
command = 'git -C %s push --set-upstream origin %s' % (self.folder, currentBranch)
|
command = 'git -C %s push --set-upstream origin %s' % (self.folder, currentBranch)
|
||||||
commandStatus = ProcessUtilities.outputExecutioner(command, self.externalApp)
|
commandStatus = ProcessUtilities.outputExecutioner(command )
|
||||||
|
|
||||||
if commandStatus.find('Everything up-to-date') == -1 and commandStatus.find('rejected') == -1:
|
if commandStatus.find('Everything up-to-date') == -1 and commandStatus.find('rejected') == -1:
|
||||||
data_ret = {'status': 1, 'commandStatus': commandStatus}
|
data_ret = {'status': 1, 'commandStatus': commandStatus}
|
||||||
@@ -3366,9 +3381,9 @@ StrictHostKeyChecking no
|
|||||||
|
|
||||||
## Set defauly key
|
## Set defauly key
|
||||||
|
|
||||||
externalApp = Websites.objects.get(domain=self.domain).externalApp
|
website = Websites.objects.get(domain=self.domain)
|
||||||
|
|
||||||
command = 'git config --global core.sshCommand "ssh -i /home/%s/.ssh/%s -o "StrictHostKeyChecking=no""' % (self.domain, externalApp)
|
command = 'git config --global core.sshCommand "ssh -i /home/%s/.ssh/%s -o "StrictHostKeyChecking=no""' % (self.domain, website.externalApp)
|
||||||
ProcessUtilities.executioner(command)
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
##
|
##
|
||||||
@@ -3383,6 +3398,12 @@ StrictHostKeyChecking no
|
|||||||
fm = FileManager(None, None)
|
fm = FileManager(None, None)
|
||||||
fm.fixPermissions(self.domain)
|
fm.fixPermissions(self.domain)
|
||||||
|
|
||||||
|
command = 'git -C %s config --local user.email %s' % (self.folder, website.adminEmail)
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
|
command = 'git -C %s config --local user.name "%s %s"' % (self.folder, website.admin.firstName, website.admin.lastName)
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
data_ret = {'status': 1, 'commandStatus': commandStatus}
|
data_ret = {'status': 1, 'commandStatus': commandStatus}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
@@ -3424,7 +3445,7 @@ StrictHostKeyChecking no
|
|||||||
return ACLManager.loadErrorJson()
|
return ACLManager.loadErrorJson()
|
||||||
|
|
||||||
command = 'rm -rf %s/.git' % (self.folder)
|
command = 'rm -rf %s/.git' % (self.folder)
|
||||||
ProcessUtilities.executioner(command, self.externalApp)
|
ProcessUtilities.executioner(command )
|
||||||
|
|
||||||
data_ret = {'status': 1}
|
data_ret = {'status': 1}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
@@ -3456,7 +3477,7 @@ StrictHostKeyChecking no
|
|||||||
return ACLManager.loadErrorJson()
|
return ACLManager.loadErrorJson()
|
||||||
|
|
||||||
command = 'cat %s/.gitignore' % (self.folder)
|
command = 'cat %s/.gitignore' % (self.folder)
|
||||||
gitIgnoreContent = ProcessUtilities.outputExecutioner(command, self.externalApp)
|
gitIgnoreContent = ProcessUtilities.outputExecutioner(command )
|
||||||
|
|
||||||
if gitIgnoreContent.find('No such file or directory') > -1:
|
if gitIgnoreContent.find('No such file or directory') > -1:
|
||||||
gitIgnoreContent = 'File is currently empty.'
|
gitIgnoreContent = 'File is currently empty.'
|
||||||
@@ -3542,7 +3563,7 @@ StrictHostKeyChecking no
|
|||||||
initCommand = """log --pretty=format:"%h|%s|%cn|%cd" -50"""
|
initCommand = """log --pretty=format:"%h|%s|%cn|%cd" -50"""
|
||||||
|
|
||||||
command = 'git -C %s %s' % (self.folder, initCommand)
|
command = 'git -C %s %s' % (self.folder, initCommand)
|
||||||
commits = ProcessUtilities.outputExecutioner(command, self.externalApp).split('\n')
|
commits = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||||
|
|
||||||
json_data = "["
|
json_data = "["
|
||||||
checker = 0
|
checker = 0
|
||||||
@@ -3592,7 +3613,7 @@ StrictHostKeyChecking no
|
|||||||
return ACLManager.loadErrorJson()
|
return ACLManager.loadErrorJson()
|
||||||
|
|
||||||
command = 'git -C %s diff-tree --no-commit-id --name-only -r %s' % (self.folder, self.commit)
|
command = 'git -C %s diff-tree --no-commit-id --name-only -r %s' % (self.folder, self.commit)
|
||||||
files = ProcessUtilities.outputExecutioner(command, self.externalApp).split('\n')
|
files = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||||
|
|
||||||
data_ret = {'status': 1, 'files': files}
|
data_ret = {'status': 1, 'files': files}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
@@ -3625,18 +3646,24 @@ StrictHostKeyChecking no
|
|||||||
return ACLManager.loadErrorJson()
|
return ACLManager.loadErrorJson()
|
||||||
|
|
||||||
command = 'git -C %s show %s -- %s/%s' % (self.folder, self.commit, self.folder, self.file.strip('\n').strip(' '))
|
command = 'git -C %s show %s -- %s/%s' % (self.folder, self.commit, self.folder, self.file.strip('\n').strip(' '))
|
||||||
fileChangedContent = ProcessUtilities.outputExecutioner(command, self.externalApp).split('\n')
|
fileChangedContent = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
initialNumber = 0
|
||||||
## Find initial line numbers
|
## Find initial line numbers
|
||||||
|
for items in fileChangedContent:
|
||||||
|
if len(items) == 0:
|
||||||
|
initialNumber = initialNumber + 1
|
||||||
|
elif items[0] == '@':
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
initialNumber = initialNumber + 1
|
||||||
|
|
||||||
lineNumber = int(fileChangedContent[10].split('+')[1].split(',')[0])
|
lineNumber = int(fileChangedContent[initialNumber].split('+')[1].split(',')[0])
|
||||||
fileLen = len(fileChangedContent)
|
fileLen = len(fileChangedContent)
|
||||||
finalConent = '<tr><td style="border-top: none;color:blue">%s</td><td style="border-top: none;"><p style="color:blue">%s</p></td></tr>' % ('#', fileChangedContent[10])
|
finalConent = '<tr><td style="border-top: none;color:blue">%s</td><td style="border-top: none;"><p style="color:blue">%s</p></td></tr>' % ('#', fileChangedContent[initialNumber])
|
||||||
|
|
||||||
for i in range(11, fileLen-1):
|
|
||||||
|
|
||||||
|
for i in range(initialNumber + 1, fileLen-1):
|
||||||
if fileChangedContent[i][0] == '@':
|
if fileChangedContent[i][0] == '@':
|
||||||
lineNumber = int(fileChangedContent[i].split('+')[1].split(',')[0])
|
lineNumber = int(fileChangedContent[i].split('+')[1].split(',')[0])
|
||||||
finalConent = finalConent + '<tr><td style="border-top: none;color:blue">%s</td><td style="border-top: none;"><p style="color:blue">%s</p></td></tr>' % ('#', fileChangedContent[i])
|
finalConent = finalConent + '<tr><td style="border-top: none;color:blue">%s</td><td style="border-top: none;"><p style="color:blue">%s</p></td></tr>' % ('#', fileChangedContent[i])
|
||||||
@@ -3644,22 +3671,25 @@ StrictHostKeyChecking no
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
if fileChangedContent[i][0] == '+':
|
if fileChangedContent[i][0] == '+':
|
||||||
content = '<p style="color:green">%s</p>' % (fileChangedContent[i])
|
content = '<p style="color:green">%s</p>' % (fileChangedContent[i].replace('<', "<").replace('>', ">"))
|
||||||
finalConent = finalConent + '<tr style="color:green"><td style="border-top: none;">%s</td><td style="border-top: none;">%s</td></tr>' % (str(lineNumber), content)
|
finalConent = finalConent + '<tr style="color:green"><td style="border-top: none;">%s</td><td style="border-top: none;">%s</td></tr>' % (str(lineNumber), content)
|
||||||
lineNumber = lineNumber + 1
|
lineNumber = lineNumber + 1
|
||||||
elif fileChangedContent[i][0] == '-':
|
elif fileChangedContent[i][0] == '-':
|
||||||
content = '<p style="color:red">%s</p>' % (fileChangedContent[i])
|
content = '<p style="color:red">%s</p>' % (fileChangedContent[i].replace('<', "<").replace('>', ">"))
|
||||||
finalConent = finalConent + '<tr style="color:red"><td style="border-top: none;">%s</td><td style="border-top: none;">%s</td></tr>' % (str(lineNumber), content)
|
finalConent = finalConent + '<tr style="color:red"><td style="border-top: none;">%s</td><td style="border-top: none;">%s</td></tr>' % (str(lineNumber), content)
|
||||||
lineNumber = lineNumber + 1
|
lineNumber = lineNumber + 1
|
||||||
else:
|
else:
|
||||||
content = '<p>%s</p>' % (fileChangedContent[i])
|
content = '<p>%s</p>' % (fileChangedContent[i].replace('<', "<").replace('>', ">"))
|
||||||
finalConent = finalConent + '<tr><td style="border-top: none;">%s</td><td style="border-top: none;">%s</td></tr>' % (str(lineNumber), content)
|
finalConent = finalConent + '<tr><td style="border-top: none;">%s</td><td style="border-top: none;">%s</td></tr>' % (str(lineNumber), content)
|
||||||
lineNumber = lineNumber + 1
|
lineNumber = lineNumber + 1
|
||||||
|
|
||||||
data_ret = {'status': 1, 'fileChangedContent': finalConent}
|
data_ret = {'status': 1, 'fileChangedContent': finalConent}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
except IndexError:
|
||||||
|
data_ret = {'status': 0, 'error_message': 'Not a text file.'}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
|
|||||||
Reference in New Issue
Block a user