Delete existing repo if the new one has a different URL. Fixed bug that could cause repeated installation.
This commit is contained in:
parent
45c19e365d
commit
78b40e6363
@ -1822,6 +1822,15 @@ class Admin extends \Zotlabs\Web\Controller {
|
|||||||
// clone the repo if new automatically
|
// clone the repo if new automatically
|
||||||
$git = new GitRepo('sys', $repoURL, true, $repoName, $repoDir);
|
$git = new GitRepo('sys', $repoURL, true, $repoName, $repoDir);
|
||||||
|
|
||||||
|
$remotes = $git->git->remote();
|
||||||
|
$fetchURL = $remotes['origin']['fetch'];
|
||||||
|
if($fetchURL !== $git->url) {
|
||||||
|
if(rrmdir($repoDir)) {
|
||||||
|
$git = new GitRepo('sys', $repoURL, true, $repoName, $repoDir);
|
||||||
|
} else {
|
||||||
|
json_return_and_die(array('message' => 'Error deleting existing addon repo.', 'success' => false));
|
||||||
|
}
|
||||||
|
}
|
||||||
$repo = $git->probeRepo();
|
$repo = $git->probeRepo();
|
||||||
$repo['readme'] = $repo['manifest'] = null;
|
$repo['readme'] = $repo['manifest'] = null;
|
||||||
foreach ($git->git->tree('master') as $object) {
|
foreach ($git->git->tree('master') as $object) {
|
||||||
|
@ -50,7 +50,12 @@
|
|||||||
{{$newRepoModal}}
|
{{$newRepoModal}}
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
// TODO: Implement a simple interface controller that reconfigures the modal dialog
|
||||||
|
// for each action in a more organized way
|
||||||
|
|
||||||
function adminPluginsAddRepo() {
|
function adminPluginsAddRepo() {
|
||||||
|
$("#generic-modal-ok-{{$newRepoModalID}}").removeClass('btn-success');
|
||||||
|
$("#generic-modal-ok-{{$newRepoModalID}}").addClass('btn-primary');
|
||||||
var repoURL = $('#id_repoURL').val();
|
var repoURL = $('#id_repoURL').val();
|
||||||
var repoName = $('#id_repoName').val();
|
var repoName = $('#id_repoName').val();
|
||||||
$('#chat-rotator').spin('tiny');
|
$('#chat-rotator').spin('tiny');
|
||||||
@ -65,6 +70,7 @@
|
|||||||
modalBody.append('<h4>Branches</h4><p>'+JSON.stringify(response.repo.branches)+'</p>');
|
modalBody.append('<h4>Branches</h4><p>'+JSON.stringify(response.repo.branches)+'</p>');
|
||||||
modalBody.append('<h4>Remotes</h4><p>'+JSON.stringify(response.repo.remote)+'</p>');
|
modalBody.append('<h4>Remotes</h4><p>'+JSON.stringify(response.repo.remote)+'</p>');
|
||||||
$('.modal-dialog').width('80%');
|
$('.modal-dialog').width('80%');
|
||||||
|
$("#generic-modal-ok-{{$newRepoModalID}}").off('click');
|
||||||
$("#generic-modal-ok-{{$newRepoModalID}}").click(function () {
|
$("#generic-modal-ok-{{$newRepoModalID}}").click(function () {
|
||||||
installAddonRepo();
|
installAddonRepo();
|
||||||
});
|
});
|
||||||
@ -78,7 +84,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function installAddonRepo() {
|
function installAddonRepo() {
|
||||||
// TODO: Link store/git/sys/reponame to /extend/addon/ and run util/add_addon_repo script
|
|
||||||
var repoURL = $('#id_repoURL').val();
|
var repoURL = $('#id_repoURL').val();
|
||||||
var repoName = $('#id_repoName').val();
|
var repoName = $('#id_repoName').val();
|
||||||
$.post(
|
$.post(
|
||||||
@ -93,6 +98,8 @@
|
|||||||
$('.modal-dialog').width('80%');
|
$('.modal-dialog').width('80%');
|
||||||
//$("#generic-modal-cancel-{{$newRepoModalID}}").hide();
|
//$("#generic-modal-cancel-{{$newRepoModalID}}").hide();
|
||||||
$("#generic-modal-ok-{{$newRepoModalID}}").html('OK');
|
$("#generic-modal-ok-{{$newRepoModalID}}").html('OK');
|
||||||
|
$("#generic-modal-ok-{{$newRepoModalID}}").removeClass('btn-primary');
|
||||||
|
$("#generic-modal-ok-{{$newRepoModalID}}").addClass('btn-success');
|
||||||
$("#generic-modal-ok-{{$newRepoModalID}}").off('click');
|
$("#generic-modal-ok-{{$newRepoModalID}}").off('click');
|
||||||
$("#generic-modal-ok-{{$newRepoModalID}}").click(function () {
|
$("#generic-modal-ok-{{$newRepoModalID}}").click(function () {
|
||||||
$('#generic-modal-{{$newRepoModalID}}').modal('hide');
|
$('#generic-modal-{{$newRepoModalID}}').modal('hide');
|
||||||
@ -111,8 +118,6 @@
|
|||||||
'json');
|
'json');
|
||||||
}
|
}
|
||||||
function updateAddonRepo(repoName) {
|
function updateAddonRepo(repoName) {
|
||||||
window.console.log('updateAddonRep:; ' + repoName);
|
|
||||||
// TODO: Update an existing repo
|
|
||||||
if(confirm('Are you sure you want to update the addon repo ' + repoName + '?')) {
|
if(confirm('Are you sure you want to update the addon repo ' + repoName + '?')) {
|
||||||
$.post(
|
$.post(
|
||||||
"/admin/plugins/updaterepo", {repoName: repoName},
|
"/admin/plugins/updaterepo", {repoName: repoName},
|
||||||
@ -135,7 +140,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function removeAddonRepo(repoName) {
|
function removeAddonRepo(repoName) {
|
||||||
window.console.log('removeAddonRepo: ' + repoName);
|
|
||||||
// TODO: Unlink the addons
|
// TODO: Unlink the addons
|
||||||
if(confirm('Are you sure you want to remove the addon repo ' + repoName + '?')) {
|
if(confirm('Are you sure you want to remove the addon repo ' + repoName + '?')) {
|
||||||
$.post(
|
$.post(
|
||||||
|
Reference in New Issue
Block a user