mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-08 06:16:08 +01:00
fetch git branches
This commit is contained in:
@@ -5823,6 +5823,8 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
||||
if (response.data.repo === 1) {
|
||||
$scope.gitTracking = true;
|
||||
$scope.gitEnable = false;
|
||||
$scope.branches = response.data.finalBranches;
|
||||
$scope.deploymentKey = response.data.deploymentKey;
|
||||
} else {
|
||||
$scope.gitTracking = false;
|
||||
$scope.gitEnable = true;
|
||||
|
||||
@@ -33,28 +33,61 @@
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<p style="margin: 2%" ng-hide="gitTracking">{% trans "This folder does not have Git tracking, click below to initiate a repository and start tracking files." %}</p>
|
||||
<button ng-hide="gitTracking" style="margin-left: 2%" type="button" class="btn btn-primary"
|
||||
<p style="margin: 2%"
|
||||
ng-hide="gitTracking">{% trans "This folder does not have Git tracking, click below to initiate a repository and start tracking files." %}</p>
|
||||
<button ng-hide="gitTracking" style="margin-left: 2%" type="button" class="btn btn-primary"
|
||||
ng-click="initRepo()">
|
||||
Init Repo
|
||||
</button>
|
||||
|
||||
<form action="/" class="form-horizontal bordered-row">
|
||||
|
||||
<div class="form-group">
|
||||
|
||||
<div class="col-sm-12">
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "Deployment Key" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<textarea rows="5"
|
||||
class="form-control">{$ deploymentKey $}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<table ng-hide="gitEnable" style="margin-top: 2%" class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Folder</th>
|
||||
<th>Remote</th>
|
||||
<th>Branch</th>
|
||||
<th>Remote</th>
|
||||
<th>Status</th>
|
||||
<th>Manage</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="record in records | filter:logSearch">
|
||||
<td ng-bind="record.domain"></td>
|
||||
<td ng-bind="record.ipAddress"></td>
|
||||
<td ng-bind="record.time"></td>
|
||||
<td ng-bind="record.resource"></td>
|
||||
<td ng-bind="record.size"></td>
|
||||
<tr>
|
||||
<td>
|
||||
<select ng-change="fetchFolderDetails()" ng-model="branchName" class="form-control">
|
||||
<option ng-repeat="branch in branches track by $index">{$ branch $}</option>
|
||||
</select></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -147,13 +147,13 @@
|
||||
|
||||
<div class="tab-pane fade" id="tab-example-3">
|
||||
|
||||
<form action="/" class="form-horizontal bordered-row">
|
||||
<form action="/" class="form-horizontal bordered-row">
|
||||
|
||||
<!------ List of records --------------->
|
||||
|
||||
<div class="form-group">
|
||||
|
||||
<div class="col-sm-12">
|
||||
<div class="col-sm-12">
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
@@ -166,7 +166,8 @@
|
||||
<td>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<textarea rows="5" class="form-control">{{ deploymentKey }}</textarea>
|
||||
<textarea rows="5"
|
||||
class="form-control">{{ deploymentKey }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
@@ -177,8 +178,7 @@
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!------ List of records --------------->
|
||||
<!------ List of records --------------->
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
@@ -2070,7 +2070,7 @@ StrictHostKeyChecking no
|
||||
command = 'mv %s /home/%s/.ssh/config' % (path, self.domain)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'sudo chown %s:%s /home/%s/.ssh/config' % (website.externalApp, website.externalApp, self.domain)
|
||||
command = 'chown %s:%s /home/%s/.ssh/config' % (website.externalApp, website.externalApp, self.domain)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'cat /home/%s/.ssh/%s.pub' % (self.domain, website.externalApp)
|
||||
@@ -2934,8 +2934,9 @@ StrictHostKeyChecking no
|
||||
return ACLManager.loadErrorJson()
|
||||
|
||||
|
||||
gitPath = '%s/.git' % (self.folder)
|
||||
website = Websites.objects.get(domain=self.domain)
|
||||
|
||||
gitPath = '%s/.git' % (self.folder)
|
||||
command = 'ls -la %s' % (gitPath)
|
||||
|
||||
if ProcessUtilities.outputExecutioner(command).find('No such file or directory') > -1:
|
||||
@@ -2943,7 +2944,38 @@ StrictHostKeyChecking no
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
else:
|
||||
data_ret = {'status': 1, 'repo': 1}
|
||||
|
||||
## Find git branches
|
||||
|
||||
command = 'git --git-dir=%s/.git branch' % (self.folder)
|
||||
branches = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
|
||||
## Fetch key
|
||||
|
||||
command = 'cat /home/%s/.ssh/config' % (self.domain)
|
||||
|
||||
if ProcessUtilities.outputExecutioner(command).find('No such file or directory') == -1:
|
||||
|
||||
configContent = """Host github.com
|
||||
IdentityFile /home/%s/.ssh/%s
|
||||
StrictHostKeyChecking no
|
||||
""" % (self.domain, website.externalApp)
|
||||
|
||||
path = "/home/cyberpanel/config"
|
||||
writeToFile = open(path, 'w')
|
||||
writeToFile.writelines(configContent)
|
||||
writeToFile.close()
|
||||
|
||||
command = 'mv %s /home/%s/.ssh/config' % (path, self.domain)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'chown %s:%s /home/%s/.ssh/config' % (website.externalApp, website.externalApp, self.domain)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'cat /home/%s/.ssh/%s.pub' % (self.domain, website.externalApp)
|
||||
deploymentKey = ProcessUtilities.outputExecutioner(command, website.externalApp)
|
||||
|
||||
data_ret = {'status': 1, 'repo': 1, 'finalBranches': branches, 'deploymentKey': deploymentKey}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user