diff --git a/websiteFunctions/static/websiteFunctions/websiteFunctions.js b/websiteFunctions/static/websiteFunctions/websiteFunctions.js index 9db2d27e9..c2d8ad3a1 100755 --- a/websiteFunctions/static/websiteFunctions/websiteFunctions.js +++ b/websiteFunctions/static/websiteFunctions/websiteFunctions.js @@ -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; diff --git a/websiteFunctions/templates/websiteFunctions/manageGIT.html b/websiteFunctions/templates/websiteFunctions/manageGIT.html index c4220583f..e83db9cc8 100755 --- a/websiteFunctions/templates/websiteFunctions/manageGIT.html +++ b/websiteFunctions/templates/websiteFunctions/manageGIT.html @@ -33,28 +33,61 @@ -

{% trans "This folder does not have Git tracking, click below to initiate a repository and start tracking files." %}

- + +
+ +
+ +
+ + + + + + + + + + + + +
{% trans "Deployment Key" %}
+
+
+ +
+
+
+
+
+ +
+ - - + - - - - - - + + + + +
FolderRemote BranchRemote Status Manage
+
diff --git a/websiteFunctions/templates/websiteFunctions/setupGit.html b/websiteFunctions/templates/websiteFunctions/setupGit.html index 56075ba1e..55edf971a 100755 --- a/websiteFunctions/templates/websiteFunctions/setupGit.html +++ b/websiteFunctions/templates/websiteFunctions/setupGit.html @@ -147,13 +147,13 @@
-
+
-
+
@@ -166,7 +166,8 @@ @@ -177,8 +178,7 @@ - - + diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py index e7302a339..779a7717f 100755 --- a/websiteFunctions/website.py +++ b/websiteFunctions/website.py @@ -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)
- +