mirror of
https://github.com/S2-/gitlit
synced 2025-08-03 21:00:04 +02:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
b841785adb | |||
9eae13612e | |||
36f71da17a | |||
e0f88f12e1 | |||
c7dab12990 | |||
9b0377efc9 |
@@ -43,16 +43,18 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (notification.event && notification.event === 'unlock') {
|
if (notification.event && notification.event === 'unlock') {
|
||||||
$('[data-file="' + notification.file + '"].js-unlock').hide();
|
let file = notification.file.replace(/\\/g, '\\\\');
|
||||||
$('[data-file="' + notification.file + '"].js-lock').show();
|
$('[data-file="' + file + '"].js-unlock').hide();
|
||||||
|
$('[data-file="' + file + '"].js-lock').show();
|
||||||
let text = 'not locked';
|
let text = 'not locked';
|
||||||
$('[data-file="' + notification.file + '"]').parent().prev().text(text);
|
$('[data-file="' + file + '"]').parent().prev().text(text);
|
||||||
}
|
}
|
||||||
if (notification.event && notification.event === 'lock') {
|
if (notification.event && notification.event === 'lock') {
|
||||||
$('[data-file="' + notification.file + '"].js-lock').hide();
|
let file = notification.file.replace(/\\/g, '\\\\');
|
||||||
$('[data-file="' + notification.file + '"].js-unlock').show();
|
$('[data-file="' + file + '"].js-lock').hide();
|
||||||
|
$('[data-file="' + file + '"].js-unlock').show();
|
||||||
let text = notification.data.owner.name + ' (id: ' + notification.data.id + ')';
|
let text = notification.data.owner.name + ' (id: ' + notification.data.id + ')';
|
||||||
$('[data-file="' + notification.file + '"]').parent().prev().text(text);
|
$('[data-file="' + file + '"]').parent().prev().text(text);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
39
app/main.js
39
app/main.js
@@ -10,9 +10,10 @@ const args = require('minimist')(process.defaultApp ? process.argv.slice(3) : pr
|
|||||||
});
|
});
|
||||||
|
|
||||||
const repoDir = path.resolve(path.normalize(args._.join(' ')));
|
const repoDir = path.resolve(path.normalize(args._.join(' ')));
|
||||||
|
let repoRootDir = repoDir;
|
||||||
|
|
||||||
function getLfsFileList(dir, cb) {
|
function getLfsFileList(dir, cb) {
|
||||||
exec('git lfs ls-files', {
|
exec('git ls-files | git check-attr --stdin lockable', {
|
||||||
maxBuffer: 1024 * 1024,
|
maxBuffer: 1024 * 1024,
|
||||||
cwd: dir
|
cwd: dir
|
||||||
},
|
},
|
||||||
@@ -26,11 +27,12 @@ function getLfsFileList(dir, cb) {
|
|||||||
if (stdout) {
|
if (stdout) {
|
||||||
let files = stdout.split('\n');
|
let files = stdout.split('\n');
|
||||||
files.forEach((file) => {
|
files.forEach((file) => {
|
||||||
let pos = file.search(/ \* | \- /);
|
let pos = file.split(': lockable: ');
|
||||||
if (pos) {
|
if (pos && pos.length === 2) {
|
||||||
file = file.substring(pos + 3);
|
file = pos[0];
|
||||||
if (file) {
|
status = pos[1];
|
||||||
parsedFiles.push(file.trim());
|
if (file && status === 'set') {
|
||||||
|
parsedFiles.push(path.normalize(file.trim()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -58,7 +60,7 @@ function getLfsLocks(dir, cb) {
|
|||||||
let files = stdout.split('\n');
|
let files = stdout.split('\n');
|
||||||
files.forEach((file) => {
|
files.forEach((file) => {
|
||||||
if (file) {
|
if (file) {
|
||||||
let fileName = file.split('\t')[0].trim();
|
let fileName = path.normalize(file.split('\t')[0].trim());
|
||||||
let lockedBy = file.split('\t')[1].trim();
|
let lockedBy = file.split('\t')[1].trim();
|
||||||
let id = file.split('ID:')[1].trim();
|
let id = file.split('ID:')[1].trim();
|
||||||
parsedFiles.push({
|
parsedFiles.push({
|
||||||
@@ -120,12 +122,13 @@ function createWindow() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let allFiles = [];
|
let allFiles = [];
|
||||||
|
let repoDirWithoutRoot = repoDir === repoRootDir ? '' : repoDir.replace(path.normalize(repoRootDir + '/'), '');
|
||||||
|
|
||||||
files.forEach((file) => {
|
files.forEach((file) => {
|
||||||
const t = {
|
const t = {
|
||||||
file: file,
|
file: file,
|
||||||
lockedBy: getArrayObjectByKey(lockedFiles, 'file', file, 'lockedBy'),
|
lockedBy: getArrayObjectByKey(lockedFiles, 'file', path.normalize(repoDirWithoutRoot ? repoDirWithoutRoot + '/' + file : file), 'lockedBy'),
|
||||||
id: getArrayObjectByKey(lockedFiles, 'file', file, 'id')
|
id: getArrayObjectByKey(lockedFiles, 'file', path.normalize(repoDirWithoutRoot ? repoDirWithoutRoot + '/' + file : file), 'id')
|
||||||
};
|
};
|
||||||
|
|
||||||
allFiles.push(t);
|
allFiles.push(t);
|
||||||
@@ -184,7 +187,23 @@ ipcMain.on('lock', (event, file) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on('ready', createWindow);
|
app.on('ready', () => {
|
||||||
|
exec('git rev-parse --show-toplevel', {
|
||||||
|
maxBuffer: 1024 * 1024,
|
||||||
|
cwd: repoDir
|
||||||
|
},
|
||||||
|
(error, stdout, stderr) => {
|
||||||
|
if (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stdout) {
|
||||||
|
repoRootDir = path.normalize(stdout.replace(/\n/g, ''));
|
||||||
|
}
|
||||||
|
|
||||||
|
createWindow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
app.on('window-all-closed', function() {
|
app.on('window-all-closed', function() {
|
||||||
if (process.platform != 'darwin') {
|
if (process.platform != 'darwin') {
|
||||||
|
2
app/package-lock.json
generated
2
app/package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gitlit-app",
|
"name": "gitlit-app",
|
||||||
"version": "1.0.5",
|
"version": "1.0.8",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gitlit-app",
|
"name": "gitlit-app",
|
||||||
"version": "1.0.5",
|
"version": "1.0.8",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
Reference in New Issue
Block a user