mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Return more detailed information on /project/branches api
This commit is contained in:
parent
3adfe249b0
commit
d007623347
@ -581,7 +581,7 @@ RED.projects = (function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -852,7 +852,6 @@ RED.projects = (function() {
|
|||||||
var branchFilterTerm = "";
|
var branchFilterTerm = "";
|
||||||
var branchFilterCreateItem;
|
var branchFilterCreateItem;
|
||||||
var branches = [];
|
var branches = [];
|
||||||
var currentBranch;
|
|
||||||
var branchPrefix = "";
|
var branchPrefix = "";
|
||||||
var container = $('<div class="projects-branch-list">').appendTo(options.container);
|
var container = $('<div class="projects-branch-list">').appendTo(options.container);
|
||||||
|
|
||||||
@ -882,15 +881,15 @@ RED.projects = (function() {
|
|||||||
scrollOnAdd: false,
|
scrollOnAdd: false,
|
||||||
addItem: function(row,index,entry) {
|
addItem: function(row,index,entry) {
|
||||||
var container = $('<div class="sidebar-version-control-branch-list-entry">').appendTo(row);
|
var container = $('<div class="sidebar-version-control-branch-list-entry">').appendTo(row);
|
||||||
if (typeof entry !== "string") {
|
if (!entry.hasOwnProperty('commit')) {
|
||||||
branchFilterCreateItem = container;
|
branchFilterCreateItem = container;
|
||||||
$('<i class="fa fa-code-fork"></i>').appendTo(container);
|
$('<i class="fa fa-code-fork"></i>').appendTo(container);
|
||||||
$('<span>').text("Create branch:").appendTo(container);
|
$('<span>').text("Create branch:").appendTo(container);
|
||||||
$('<div class="sidebar-version-control-branch-list-entry-create-name" style="margin-left: 10px;">').text(entry.name).appendTo(container);
|
$('<div class="sidebar-version-control-branch-list-entry-create-name" style="margin-left: 10px;">').text(entry.name).appendTo(container);
|
||||||
} else {
|
} else {
|
||||||
$('<i class="fa fa-code-fork"></i>').appendTo(container);
|
$('<i class="fa fa-code-fork"></i>').appendTo(container);
|
||||||
$('<span>').text(entry).appendTo(container);
|
$('<span>').text(entry.name).appendTo(container);
|
||||||
if (currentBranch === entry) {
|
if (entry.current) {
|
||||||
container.addClass("selected");
|
container.addClass("selected");
|
||||||
$('<span class="current"></span>').text(options.currentLabel||"current").appendTo(container);
|
$('<span class="current"></span>').text(options.currentLabel||"current").appendTo(container);
|
||||||
}
|
}
|
||||||
@ -901,7 +900,7 @@ RED.projects = (function() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var body = {};
|
var body = {};
|
||||||
if (typeof entry !== "string") {
|
if (!entry.hasOwnProperty('commit')) {
|
||||||
body.name = branchFilter.val();
|
body.name = branchFilter.val();
|
||||||
body.create = true;
|
body.create = true;
|
||||||
if (options.remote) {
|
if (options.remote) {
|
||||||
@ -911,7 +910,7 @@ RED.projects = (function() {
|
|||||||
if ($(this).hasClass('selected')) {
|
if ($(this).hasClass('selected')) {
|
||||||
body.current = true;
|
body.current = true;
|
||||||
}
|
}
|
||||||
body.name = entry;
|
body.name = entry.name;
|
||||||
}
|
}
|
||||||
if (options.onselect) {
|
if (options.onselect) {
|
||||||
options.onselect(body);
|
options.onselect(body);
|
||||||
@ -919,7 +918,7 @@ RED.projects = (function() {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
filter: function(data) {
|
filter: function(data) {
|
||||||
var isCreateEntry = (typeof data !=="string");
|
var isCreateEntry = (!data.hasOwnProperty('commit'));
|
||||||
return (
|
return (
|
||||||
isCreateEntry &&
|
isCreateEntry &&
|
||||||
(
|
(
|
||||||
@ -929,7 +928,7 @@ RED.projects = (function() {
|
|||||||
) ||
|
) ||
|
||||||
(
|
(
|
||||||
!isCreateEntry &&
|
!isCreateEntry &&
|
||||||
data.indexOf(branchFilterTerm) !== -1
|
data.name.indexOf(branchFilterTerm) !== -1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -939,14 +938,12 @@ RED.projects = (function() {
|
|||||||
branchList.editableList('empty');
|
branchList.editableList('empty');
|
||||||
var start = Date.now();
|
var start = Date.now();
|
||||||
var spinner = addSpinnerOverlay(container).addClass("projects-dialog-spinner-contain");
|
var spinner = addSpinnerOverlay(container).addClass("projects-dialog-spinner-contain");
|
||||||
currentBranch = options.current();
|
|
||||||
if (options.remote) {
|
if (options.remote) {
|
||||||
branchPrefix = options.remote()+"/";
|
branchPrefix = options.remote()+"/";
|
||||||
} else {
|
} else {
|
||||||
branchPrefix = "";
|
branchPrefix = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sendRequest({
|
sendRequest({
|
||||||
url: url,
|
url: url,
|
||||||
type: "GET",
|
type: "GET",
|
||||||
@ -972,7 +969,7 @@ RED.projects = (function() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
addItem: function(data) { branchList.editableList('addItem',data) },
|
// addItem: function(data) { branchList.editableList('addItem',data) },
|
||||||
filter: function() { branchList.editableList('filter') },
|
filter: function() { branchList.editableList('filter') },
|
||||||
focus: function() { branchFilter.focus() }
|
focus: function() { branchFilter.focus() }
|
||||||
}
|
}
|
||||||
|
@ -571,9 +571,6 @@ RED.sidebar.versionControl = (function() {
|
|||||||
$('<div class="sidebar-version-control-slide-box-header"></div>').text("Change local branch").appendTo(localBranchBox);
|
$('<div class="sidebar-version-control-slide-box-header"></div>').text("Change local branch").appendTo(localBranchBox);
|
||||||
|
|
||||||
var localBranchList = utils.createBranchList({
|
var localBranchList = utils.createBranchList({
|
||||||
current: function() {
|
|
||||||
return RED.projects.getActiveProject().git.branches.local
|
|
||||||
},
|
|
||||||
placeholder: "Find or create a branch",
|
placeholder: "Find or create a branch",
|
||||||
container: localBranchBox,
|
container: localBranchBox,
|
||||||
onselect: function(body) {
|
onselect: function(body) {
|
||||||
@ -711,9 +708,6 @@ RED.sidebar.versionControl = (function() {
|
|||||||
|
|
||||||
var remoteBranchSubRow = $('<div style="height: 0;overflow:hidden; transition: height 0.2s ease-in-out;"></div>').hide().appendTo(remoteBranchRow);
|
var remoteBranchSubRow = $('<div style="height: 0;overflow:hidden; transition: height 0.2s ease-in-out;"></div>').hide().appendTo(remoteBranchRow);
|
||||||
var remoteBranchList = utils.createBranchList({
|
var remoteBranchList = utils.createBranchList({
|
||||||
current: function() {
|
|
||||||
return RED.projects.getActiveProject().git.branches.remote
|
|
||||||
},
|
|
||||||
placeholder: "Find or create a remote branch",
|
placeholder: "Find or create a remote branch",
|
||||||
currentLabel: "upstream",
|
currentLabel: "upstream",
|
||||||
remote: function() {
|
remote: function() {
|
||||||
|
@ -272,17 +272,35 @@ function getRemotes(cwd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getBranches(cwd, remote) {
|
function getBranches(cwd, remote) {
|
||||||
var args = ['branch','--no-color'];
|
var args = ['branch','-vv','--no-color'];
|
||||||
if (remote) {
|
if (remote) {
|
||||||
args.push('-r');
|
args.push('-r');
|
||||||
}
|
}
|
||||||
|
//TODO: parse out ahead/behind status (currently m[5] vvv )
|
||||||
|
var branchRE = /^([ \*] )(\S+) +(\S+)(?: \[(\S+?)(?:: (.*))?\])? (.*)$/;
|
||||||
return runGitCommand(args,cwd).then(function(output) {
|
return runGitCommand(args,cwd).then(function(output) {
|
||||||
var branches = [];
|
var branches = [];
|
||||||
var lines = output.split("\n");
|
var lines = output.split("\n");
|
||||||
branches = lines.map(function(l) { return l.substring(2)})
|
branches = lines.map(function(l) {
|
||||||
.filter(function(l) {
|
var m = branchRE.exec(l);
|
||||||
return !/HEAD ->/.test(l) && (l.length > 0)
|
var branch = null;
|
||||||
});
|
if (m) {
|
||||||
|
branch = {
|
||||||
|
name: m[2],
|
||||||
|
remote: m[4],
|
||||||
|
status: m[5],
|
||||||
|
commit: {
|
||||||
|
sha: m[3],
|
||||||
|
subject: m[6]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (m[1] === '* ') {
|
||||||
|
branch.current = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return branch;
|
||||||
|
}).filter(function(v) { return !!v && v.commit.sha !== '->' });
|
||||||
|
|
||||||
return {branches:branches};
|
return {branches:branches};
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user