mirror of
https://github.com/S2-/gitlit
synced 2025-08-02 20:30:05 +02:00
Compare commits
98 Commits
Author | SHA1 | Date | |
---|---|---|---|
ce50a38e35
|
|||
133f72df2a
|
|||
bebaf95f70
|
|||
e719261427
|
|||
1fe4d0d90c
|
|||
9873246826
|
|||
b8a94f650f
|
|||
e97a5c1fc2
|
|||
3d020a3ddd
|
|||
8765f99f19
|
|||
cee594fcd9
|
|||
3c4d33eb83
|
|||
48b5f33eb9
|
|||
64b500f414
|
|||
caeaab14b8
|
|||
94e7c5ce71
|
|||
cdafb7a006
|
|||
6c2bc3397e
|
|||
a6666452d7
|
|||
e9feebce51
|
|||
510e4786b7
|
|||
b540eae1b9
|
|||
8f3705ba74
|
|||
e032eb2ab0
|
|||
519d719545
|
|||
f8076499ba
|
|||
edeadfd7fc
|
|||
9c26b8fb10
|
|||
b0f3ba27b5 | |||
99c858e5a7 | |||
9f02f5f27c | |||
48ecb505d7 | |||
a04c84abb4 | |||
31c19d5534 | |||
171b79e355 | |||
4178caa94a | |||
7cae3f33ec | |||
3952948a15 | |||
011a78a75f | |||
e0ad69a5b1 | |||
e994b98dcc | |||
6431183092 | |||
28acea0c74 | |||
f69e80e306 | |||
81fd51656e | |||
b54fb104be | |||
1072c27e6d | |||
ead56bac77 | |||
4eef037145 | |||
2be62645d9 | |||
5abd0d6f27 | |||
8fb44bc439 | |||
42c754d5c2 | |||
4d28e8495d | |||
28662aa961 | |||
67be0c888e | |||
769ea1ce73 | |||
5fef5c7236 | |||
81e88046d2 | |||
c577446cc5 | |||
b841785adb | |||
9eae13612e | |||
36f71da17a | |||
e0f88f12e1 | |||
c7dab12990 | |||
9b0377efc9 | |||
029712a32b | |||
1718c7652e | |||
1313cff86a | |||
c5f9b551ab | |||
e2a57318a7 | |||
17bb850527 | |||
3111f2b327 | |||
d24a82e91e | |||
3dcadb39c2 | |||
dfa91111a6 | |||
51a6fd153f | |||
6d71042f69 | |||
cae59c6a72 | |||
cf51498711 | |||
c910dd25a5 | |||
066e46a202 | |||
325c4479cc | |||
3c557f7ce5 | |||
613525752b | |||
ec1931ca52 | |||
5c55c54b71 | |||
da4083f574 | |||
4fcc873901 | |||
ae314d1d0a | |||
cb87d6a9cd | |||
d002126b72 | |||
e8c95255e8 | |||
dec767fe75 | |||
2c5b23c10e | |||
0ea0853165 | |||
6227e2328b | |||
67add0f1de |
1
.eslintignore
Normal file
1
.eslintignore
Normal file
@@ -0,0 +1 @@
|
||||
node_modules
|
33
.eslintrc.json
Normal file
33
.eslintrc.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{"parserOptions":
|
||||
{"ecmaVersion": 6},
|
||||
"rules": {
|
||||
"quotes": [2, "single", {"allowTemplateLiterals": true}],
|
||||
"curly": [2, "all"],
|
||||
"keyword-spacing": [2, {"overrides": {"else": {"before": true}, "catch": {"before": true, "after": false}}}],
|
||||
"space-before-blocks": [2, "always"],
|
||||
"wrap-iife": [2, "inside"],
|
||||
"space-before-function-paren": [2, "never"],
|
||||
"one-var": [2, "never"],
|
||||
"vars-on-top": 0, "no-empty": [2, {"allowEmptyCatch": true}],
|
||||
"array-bracket-spacing": [2, "never"],
|
||||
"space-in-parens": [2, "never"],
|
||||
"no-underscore-dangle": 0,
|
||||
"comma-style": [2, "last"],
|
||||
"comma-spacing": [2, {"before": false, "after": true}],
|
||||
"space-unary-ops": [2, {"words": false, "nonwords": false}],
|
||||
"no-multi-spaces": 2,
|
||||
"space-infix-ops": 2,
|
||||
"no-with": 2,
|
||||
"indent": [2, "tab", {"SwitchCase": 1, "FunctionExpression": {"body": 1, "parameters": 1}, "MemberExpression": 0}],
|
||||
"no-mixed-spaces-and-tabs": 2,
|
||||
"no-trailing-spaces": 2,
|
||||
"comma-dangle": [2, "never"],
|
||||
"semi": [2, "always"],
|
||||
"brace-style": [2, "1tbs", {"allowSingleLine": true}],
|
||||
"eol-last": 2,
|
||||
"dot-notation": 0,
|
||||
"no-multi-str": 2,
|
||||
"key-spacing": [2, {"afterColon": true}],
|
||||
"func-call-spacing": [2, "never"]
|
||||
}
|
||||
}
|
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,3 +1,3 @@
|
||||
node_modules
|
||||
app/node_modules
|
||||
dist
|
||||
node_modules
|
||||
.vscode
|
||||
|
78
.jscsrc
78
.jscsrc
@@ -1,78 +0,0 @@
|
||||
{
|
||||
"requireCurlyBraces": [
|
||||
"if",
|
||||
"else",
|
||||
"for",
|
||||
"while",
|
||||
"do",
|
||||
"try",
|
||||
"catch"
|
||||
],
|
||||
"requireSpaceAfterKeywords": [
|
||||
"if",
|
||||
"else",
|
||||
"for",
|
||||
"while",
|
||||
"do",
|
||||
"switch",
|
||||
"case",
|
||||
"return",
|
||||
"try"
|
||||
],
|
||||
"requireSpaceBeforeKeywords": [
|
||||
"else",
|
||||
"catch"
|
||||
],
|
||||
"disallowSpaceAfterKeywords": [
|
||||
"catch"
|
||||
],
|
||||
"requireSpaceBeforeBlockStatements": true,
|
||||
"requireParenthesesAroundIIFE": true,
|
||||
"requireSpacesInConditionalExpression": true,
|
||||
"disallowSpacesInNamedFunctionExpression": {
|
||||
"beforeOpeningRoundBrace": true
|
||||
},
|
||||
"disallowSpacesInFunctionDeclaration": {
|
||||
"beforeOpeningRoundBrace": true
|
||||
},
|
||||
"disallowSpacesInFunctionExpression": {
|
||||
"beforeOpeningRoundBrace": true
|
||||
},
|
||||
"requireSpaceBetweenArguments": true,
|
||||
"disallowMultipleVarDecl": true,
|
||||
"requireVarDeclFirst": false,
|
||||
"requireBlocksOnNewline": false,
|
||||
"disallowEmptyBlocks": true,
|
||||
"disallowSpacesInsideArrayBrackets": true,
|
||||
"disallowSpacesInsideObjectBrackets": true,
|
||||
"disallowSpacesInsideParentheses": true,
|
||||
"disallowDanglingUnderscores": false,
|
||||
"requireCommaBeforeLineBreak": true,
|
||||
"disallowSpaceAfterPrefixUnaryOperators": true,
|
||||
"disallowSpaceBeforePostfixUnaryOperators": true,
|
||||
"disallowSpaceBeforeBinaryOperators": [
|
||||
","
|
||||
],
|
||||
"requireSpacesInForStatement": true,
|
||||
"requireSpacesInAnonymousFunctionExpression": {
|
||||
"beforeOpeningCurlyBrace": true
|
||||
},
|
||||
"requireSpaceBeforeBinaryOperators": true,
|
||||
"requireSpaceAfterBinaryOperators": true,
|
||||
"disallowKeywords": [
|
||||
"with"
|
||||
],
|
||||
"validateIndentation": "\t",
|
||||
"disallowMixedSpacesAndTabs": true,
|
||||
"disallowTrailingWhitespace": true,
|
||||
"disallowTrailingComma": true,
|
||||
"disallowKeywordsOnNewLine": [
|
||||
"else"
|
||||
],
|
||||
"requireLineFeedAtFileEnd": true,
|
||||
"requireCapitalizedConstructors": true,
|
||||
"requireDotNotation": false,
|
||||
"disallowNewlineBeforeBlockStatements": true,
|
||||
"disallowMultipleLineStrings": true,
|
||||
"requireSpaceBeforeObjectValues": true
|
||||
}
|
35
README.md
35
README.md
@@ -1,4 +1,4 @@
|
||||
# gitlit
|
||||
# <img src="logo/logo.png" alt="gitlit">
|
||||
|
||||
gitlit is a very simple desktop app that allows you to handle [git lfs file locks](https://github.com/git-lfs/git-lfs/wiki/File-Locking).
|
||||
|
||||
@@ -18,3 +18,36 @@ gitlit /home/s2/myApp
|
||||
```
|
||||
|
||||
If no folder is specified, gitlit looks at the current path.
|
||||
|
||||
You can also drag&drop a folder inside the main window.
|
||||
|
||||
## contribute
|
||||
|
||||
The code is very easy. Just clone the repo and have look!
|
||||
Use the `.eslintrc.json` for formatting the code and keep it clean and consistent.
|
||||
|
||||
There are just some js libraries:
|
||||
- [ejs](http://ejs.co/) is used for templating. The templates are in `app/js/templates.js`.
|
||||
- [sorttable.js](http://www.kryogenix.org/code/browser/sorttable/) to sort the table containing the files.
|
||||
- [jQuery](https://jquery.com/), because it's still cool to have it, even if everyone says it's dead and we should do without.
|
||||
- [Bootstrap](https://getbootstrap.com/) for the layout
|
||||
- [PNotify](https://github.com/sciactive/pnotify) for generic notifications
|
||||
|
||||
### run the app
|
||||
```
|
||||
npm install
|
||||
npm start
|
||||
```
|
||||
|
||||
### make a release
|
||||
```
|
||||
npm install
|
||||
npm run dist
|
||||
```
|
||||
|
||||
## notes
|
||||
Since version 2.0.1 the app auto updates itself using the [github-app-updater](https://www.npmjs.com/package/github-app-updater).
|
||||
|
||||
## license
|
||||
|
||||
ISC
|
||||
|
@@ -1,3 +1,12 @@
|
||||
html {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.jumbotron {
|
||||
height: 640px;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
.js-container {
|
||||
margin: 5px;
|
||||
}
|
||||
@@ -40,3 +49,13 @@ table.sortable thead {
|
||||
table.sortable .sorttable_nosort {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* updater
|
||||
*/
|
||||
.updatenotice {
|
||||
position: fixed;
|
||||
bottom: 5px;
|
||||
right: 5px;
|
||||
}
|
||||
|
@@ -3,26 +3,26 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>gitlit</title>
|
||||
|
||||
<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
|
||||
|
||||
<script src="node_modules/jquery/dist/jquery.js"></script>
|
||||
<script src="node_modules/bootstrap/dist/js/bootstrap.js"></script>
|
||||
<script type="text/javascript" src="../node_modules/jquery/dist/jquery.js"></script>
|
||||
<script type="text/javascript" src="../node_modules/bootstrap/dist/js/bootstrap.js"></script>
|
||||
|
||||
<script type="text/javascript" src="node_modules/pnotify/dist/iife/PNotify.js"></script>
|
||||
<script type="text/javascript" src="node_modules/pnotify/dist/iife/PNotifyButtons.js"></script>
|
||||
<script type="text/javascript" src="../node_modules/pnotify/dist/iife/PNotify.js"></script>
|
||||
<script type="text/javascript" src="../node_modules/pnotify/dist/iife/PNotifyButtons.js"></script>
|
||||
|
||||
<script src="node_modules/ejs/ejs.js"></script>
|
||||
<script src="js/templates.js"></script>
|
||||
<script src="js/sorttable.js"></script>
|
||||
<script type="text/javascript" src="../node_modules/ejs/ejs.js"></script>
|
||||
<script type="text/javascript" src="../node_modules/ejs-render-remote/ejs-render-remote.js"></script>
|
||||
<script type="text/javascript" src="js/sorttable.js"></script>
|
||||
|
||||
<link href="node_modules/bootstrap/dist/css/bootstrap.css" rel="stylesheet">
|
||||
<link href="../node_modules/bootstrap/dist/css/bootstrap.css" rel="stylesheet">
|
||||
<link href="css/app.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div class="js-container">
|
||||
</div>
|
||||
<div class="js-container"></div>
|
||||
<script src="js/index.js"></script>
|
||||
|
||||
<div class="js-updatenotice btn btn-warning btn-sm updatenotice" style="display:none" disabled>Update ready to install</div>
|
||||
</body>
|
||||
</html>
|
||||
|
115
app/js/index.js
115
app/js/index.js
@@ -1,29 +1,73 @@
|
||||
(function($) {
|
||||
const ipcRenderer = require('electron').ipcRenderer;
|
||||
const searchInPage = require('electron-in-page-search').default;
|
||||
const remote = require('electron').remote;
|
||||
const electronFind = require('electron-find');
|
||||
const dialog = remote.require('electron').dialog;
|
||||
|
||||
const inPageSearch = searchInPage(remote.getCurrentWebContents());
|
||||
let findInPage = new electronFind.FindInPage(remote.getCurrentWebContents());
|
||||
|
||||
let firstRun = true;
|
||||
|
||||
//events
|
||||
|
||||
//update stuff
|
||||
ipcRenderer.on('update', (event, state) => {
|
||||
if (state.event === 'updateAvailable') {
|
||||
$('.js-updatenotice').text(`New version ${state.version} available. Downloading...`);
|
||||
$('.js-updatenotice').prop('disabled', true);
|
||||
$('.js-updatenotice').show();
|
||||
}
|
||||
|
||||
if (state.event === 'updateReadyToInstall') {
|
||||
$('.js-updatenotice').text(`New version ready to install. Click here to start installer.`);
|
||||
$('.js-updatenotice').show();
|
||||
$('.js-updatenotice').prop('disabled', false);
|
||||
$('.js-updatenotice').data('file', state.file);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.js-updatenotice', (ev) => {
|
||||
ev.preventDefault();
|
||||
if ($('.js-updatenotice').prop('disabled')) {
|
||||
return;
|
||||
}
|
||||
$('.js-updatenotice').prop('disabled', true);
|
||||
$('.js-updatenotice').text(`Launching installer...`);
|
||||
ipcRenderer.send('installUpdate', $('.js-updatenotice').data('file'));
|
||||
});
|
||||
//end update stuff
|
||||
|
||||
|
||||
ipcRenderer.on('fileList', (event, files) => {
|
||||
firstRun = false;
|
||||
if (files && files.length > 0) {
|
||||
$('.files-table-container').html(gitlit.templates.files({files: files}));
|
||||
sorttable.makeSortable($('.js-filestable')[0]);
|
||||
var myTH = document.getElementsByTagName("th")[0];
|
||||
sorttable.innerSortFunction.apply(myTH, []);
|
||||
ejs.preloadTemplate('templates/files.ejs')
|
||||
.then(t => {
|
||||
$('.files-table-container').html(ejs.rr(t, {files: files}));
|
||||
sorttable.makeSortable($('.js-filestable')[0]);
|
||||
var myTH = document.getElementsByTagName('th')[0];
|
||||
sorttable.innerSortFunction.apply(myTH, []);
|
||||
});
|
||||
} else {
|
||||
$('.files-table-container').html(gitlit.templates.noGitLfsFiles());
|
||||
$('.files-table-container').html(ejs.rr('templates/noGitLfsFiles.ejs'));
|
||||
}
|
||||
});
|
||||
|
||||
ipcRenderer.on('repoDir', (event, repoDir) => {
|
||||
$('.js-repo-dir').text('current repo dir: ' + repoDir).show();
|
||||
ejs.preloadTemplate('templates/main.ejs')
|
||||
.then(t => {
|
||||
$('.js-container').html(ejs.rr(t));
|
||||
$('.js-repo-dir').text('current repo dir: ' + repoDir).show();
|
||||
});
|
||||
});
|
||||
|
||||
ipcRenderer.on('isNoGitLfsRepo', (event, repoDir) => {
|
||||
$('.js-container').html(gitlit.templates.isNoGitLfsRepo({repoDir: repoDir}));
|
||||
if (firstRun) {
|
||||
firstRun = false;
|
||||
$('.js-container').html(ejs.rr('templates/firstRun.ejs', {repoDir: repoDir}));
|
||||
} else {
|
||||
$('.js-container').html(ejs.rr('templates/isNoGitLfsRepo.ejs', {repoDir: repoDir}));
|
||||
}
|
||||
});
|
||||
|
||||
ipcRenderer.on('notification', (event, notification) => {
|
||||
@@ -45,16 +89,18 @@
|
||||
}
|
||||
|
||||
if (notification.event && notification.event === 'unlock') {
|
||||
$('[data-file="' + notification.file + '"].js-unlock').hide();
|
||||
$('[data-file="' + notification.file + '"].js-lock').show();
|
||||
let file = notification.file.replace(/\\/g, '\\\\');
|
||||
$('[data-file="' + file + '"].js-unlock').hide();
|
||||
$('[data-file="' + file + '"].js-lock').show();
|
||||
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') {
|
||||
$('[data-file="' + notification.file + '"].js-lock').hide();
|
||||
$('[data-file="' + notification.file + '"].js-unlock').show();
|
||||
let file = notification.file.replace(/\\/g, '\\\\');
|
||||
$('[data-file="' + file + '"].js-lock').hide();
|
||||
$('[data-file="' + file + '"].js-unlock').show();
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -75,19 +121,46 @@
|
||||
window.location.reload(false);
|
||||
});
|
||||
|
||||
$(document).on('click', '.js-open-folder', (ev) => {
|
||||
ev.preventDefault();
|
||||
|
||||
dialog.showOpenDialog({
|
||||
properties: ['openDirectory']
|
||||
})
|
||||
.then((path) => {
|
||||
if (path && path.filePaths.length > 0) {
|
||||
ipcRenderer.send('restart', path.filePaths[0]);
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('keypress', (ev) => {
|
||||
//ctrl + f
|
||||
if (ev.ctrlKey && ev.charCode == 6) {
|
||||
if (inPageSearch && inPageSearch.opened) {
|
||||
inPageSearch.closeSearchWindow();
|
||||
} else {
|
||||
inPageSearch.openSearchWindow();
|
||||
}
|
||||
findInPage.openFindWindow();
|
||||
}
|
||||
|
||||
//ctrl + r
|
||||
if (ev.ctrlKey && ev.keyCode == 18) {
|
||||
window.location.reload(false);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('drop', (ev) => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
if (ev.originalEvent.dataTransfer.files && ev.originalEvent.dataTransfer.files.length > 0) {
|
||||
ipcRenderer.send('restart', ev.originalEvent.dataTransfer.files[0].path);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('dragover', (ev) => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
});
|
||||
|
||||
//startup
|
||||
PNotify.defaults.styling = 'bootstrap4'; // Bootstrap version 4
|
||||
$('.js-container').html(gitlit.templates.main());
|
||||
|
||||
})(jQuery);
|
||||
|
@@ -1,63 +0,0 @@
|
||||
window.gitlit = window.gitlit || {};
|
||||
gitlit.templates = {
|
||||
main: ejs.compile(`
|
||||
<div class="alert alert-success js-repo-dir" style="display:none;"></div>
|
||||
<div class="files-table-container">
|
||||
<div class="alert alert-primary" role="alert">
|
||||
Getting file list...
|
||||
</div>
|
||||
</div>
|
||||
`),
|
||||
files: ejs.compile(`
|
||||
<table class="table table-striped sortable js-filestable">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th>file</th>
|
||||
<th>status</th>
|
||||
<th class="sorttable_nosort">action</th>
|
||||
</tr>
|
||||
<thead>
|
||||
|
||||
<tbody>
|
||||
<% files.forEach((file) => { %>
|
||||
<tr>
|
||||
<td><%= file.file %></td>
|
||||
<td><%= file.lockedBy ? file.lockedBy + ' (id: ' + file.id + ')' : 'not locked' %></td>
|
||||
<td>
|
||||
<a class="btn btn-primary btn-sm js-lock"
|
||||
href="javascript:///"
|
||||
data-file="<%= file.file %>"
|
||||
style="<%= file.lockedBy ? 'display: none;' : '' %>"
|
||||
>
|
||||
Lock
|
||||
</a>
|
||||
<a class="btn btn-danger btn-sm js-unlock"
|
||||
href="javascript:///"
|
||||
data-file="<%= file.file %>"
|
||||
style="<%= file.lockedBy ? '' : 'display: none;' %>"
|
||||
>
|
||||
Unlock
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<% }); %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="float-right">
|
||||
<a class="btn btn-secondary btn-sm js-refresh" href="javascript:///">
|
||||
Refresh
|
||||
</a>
|
||||
</div>
|
||||
`),
|
||||
isNoGitLfsRepo: ejs.compile(`
|
||||
<div class="alert alert-danger">
|
||||
<%= repoDir %> is not a git lfs repo.
|
||||
</div>
|
||||
`),
|
||||
noGitLfsFiles: ejs.compile(`
|
||||
<div class="alert alert-info">
|
||||
no files tracked with lfs here.
|
||||
</div>
|
||||
`)
|
||||
};
|
184
app/main.js
184
app/main.js
@@ -3,16 +3,56 @@ const path = require('path');
|
||||
const url = require('url');
|
||||
const electronLocalshortcut = require('electron-localshortcut');
|
||||
const exec = require('child_process').exec;
|
||||
const args = require('minimist')(process.defaultApp ? process.argv.slice(2) : process.argv.slice(1), {
|
||||
const gau = require('github-app-updater');
|
||||
const args = require('minimist')(process.defaultApp ? process.argv.slice(3) : process.argv.slice(1), {
|
||||
default: {
|
||||
_: process.cwd()
|
||||
}
|
||||
});
|
||||
|
||||
const repoDir = path.resolve(path.normalize(args._.join(' ')));
|
||||
let win;
|
||||
let repoDir = path.resolve(path.normalize(args._.join(' ')));
|
||||
let repoRootDir = repoDir;
|
||||
|
||||
//auto update stuff
|
||||
if (process.platform === 'win32') {
|
||||
setTimeout(() => {
|
||||
gau.checkForUpdate({
|
||||
currentVersion: app.getVersion(),
|
||||
repo: 'https://api.github.com/repos/S2-/gitlit/releases/latest',
|
||||
assetMatch: /.+setup.+exe/i
|
||||
});
|
||||
|
||||
gau.onUpdateAvailable = (version, asset) => {
|
||||
win.webContents.send('update', {
|
||||
event: 'updateAvailable',
|
||||
version: version
|
||||
});
|
||||
gau.downloadNewVersion(asset);
|
||||
};
|
||||
|
||||
gau.onNewVersionReadyToInstall = (file) => {
|
||||
win.webContents.send('update', {
|
||||
event: 'updateReadyToInstall',
|
||||
file: file
|
||||
});
|
||||
};
|
||||
|
||||
ipcMain.on('installUpdate', (event, file) => {
|
||||
gau.executeUpdate(file);
|
||||
win.webContents.send('update', {
|
||||
event: 'updateInstalling'
|
||||
});
|
||||
app.quit();
|
||||
});
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
//end update stuff
|
||||
|
||||
function getLfsFileList(dir, cb) {
|
||||
exec('git lfs ls-files', {
|
||||
exec('git ls-files | git check-attr --stdin lockable', {
|
||||
maxBuffer: (1024 * 1024) * 10, //10MB
|
||||
cwd: dir
|
||||
},
|
||||
(error, stdout, stderr) => {
|
||||
@@ -25,9 +65,13 @@ function getLfsFileList(dir, cb) {
|
||||
if (stdout) {
|
||||
let files = stdout.split('\n');
|
||||
files.forEach((file) => {
|
||||
file = file.split(' * ');
|
||||
if (file[1]) {
|
||||
parsedFiles.push(file[1].trim());
|
||||
let pos = file.split(': lockable: ');
|
||||
if (pos && pos.length === 2) {
|
||||
file = pos[0];
|
||||
status = pos[1];
|
||||
if (file && status === 'set') {
|
||||
parsedFiles.push(path.normalize(file.trim()));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -40,6 +84,7 @@ function getLfsFileList(dir, cb) {
|
||||
|
||||
function getLfsLocks(dir, cb) {
|
||||
exec('git lfs locks', {
|
||||
maxBuffer: (1024 * 1024) * 10, //10MB
|
||||
cwd: dir
|
||||
},
|
||||
(error, stdout, stderr) => {
|
||||
@@ -53,7 +98,7 @@ function getLfsLocks(dir, cb) {
|
||||
let files = stdout.split('\n');
|
||||
files.forEach((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 id = file.split('ID:')[1].trim();
|
||||
parsedFiles.push({
|
||||
@@ -79,11 +124,54 @@ function getArrayObjectByKey(array, key, value, defaultKeyValue) {
|
||||
return defaultKeyValue ? o[0][defaultKeyValue] : o[0];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
||||
function loadRepoPage() {
|
||||
win.webContents.send('repoDir', repoDir);
|
||||
|
||||
getLfsFileList(repoDir, (err, files) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
|
||||
win.webContents.send('isNoGitLfsRepo', repoDir);
|
||||
return;
|
||||
}
|
||||
getLfsLocks(repoDir, (err, lockedFiles) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
|
||||
win.webContents.send('isNoGitLfsRepo', repoDir);
|
||||
return;
|
||||
}
|
||||
let allFiles = [];
|
||||
let repoDirWithoutRoot = repoDir === repoRootDir ? '' : repoDir.replace(path.normalize(repoRootDir + '/'), '');
|
||||
|
||||
files.forEach((file) => {
|
||||
const t = {
|
||||
file: file,
|
||||
lockedBy: getArrayObjectByKey(lockedFiles, 'file', path.normalize(repoDirWithoutRoot ? repoDirWithoutRoot + '/' + file : file), 'lockedBy'),
|
||||
id: getArrayObjectByKey(lockedFiles, 'file', path.normalize(repoDirWithoutRoot ? repoDirWithoutRoot + '/' + file : file), 'id')
|
||||
};
|
||||
|
||||
allFiles.push(t);
|
||||
});
|
||||
|
||||
win.webContents.send('fileList', allFiles);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function createWindow() {
|
||||
// Create the browser window.
|
||||
win = new BrowserWindow({width: 800, height: 600});
|
||||
win = new BrowserWindow({
|
||||
title: 'gitlit v' + app.getVersion(),
|
||||
width: 800,
|
||||
height: 700,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
enableRemoteModule: true
|
||||
}
|
||||
});
|
||||
win.setMenu(null);
|
||||
|
||||
// and load the index.html of the app.
|
||||
@@ -91,54 +179,48 @@ function createWindow() {
|
||||
pathname: path.join(__dirname, 'index.html'),
|
||||
protocol: 'file:',
|
||||
slashes: true
|
||||
}))
|
||||
}));
|
||||
|
||||
electronLocalshortcut.register(win, 'F12', () => {
|
||||
win.webContents.toggleDevTools();
|
||||
});
|
||||
|
||||
win.webContents.on('did-finish-load', () => {
|
||||
win.webContents.send('repoDir', repoDir);
|
||||
|
||||
getLfsFileList(repoDir, (err, files) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
|
||||
win.webContents.send('isNoGitLfsRepo', repoDir);
|
||||
return;
|
||||
}
|
||||
getLfsLocks(repoDir, (err, lockedFiles) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
|
||||
win.webContents.send('isNoGitLfsRepo', repoDir);
|
||||
return;
|
||||
}
|
||||
let allFiles = [];
|
||||
|
||||
files.forEach((file) => {
|
||||
const t = {
|
||||
file: file,
|
||||
lockedBy: getArrayObjectByKey(lockedFiles, 'file', file, 'lockedBy'),
|
||||
id: getArrayObjectByKey(lockedFiles, 'file', file, 'id')
|
||||
};
|
||||
|
||||
allFiles.push(t);
|
||||
});
|
||||
|
||||
win.webContents.send('fileList', allFiles);
|
||||
});
|
||||
});
|
||||
loadRepoPage();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function startup(cb) {
|
||||
exec('git rev-parse --show-toplevel', {
|
||||
maxBuffer: (1024 * 1024) * 10, //10MB
|
||||
cwd: repoDir
|
||||
},
|
||||
(error, stdout, stderr) => {
|
||||
if (error) {
|
||||
if (win) {
|
||||
win.webContents.send('isNoGitLfsRepo', repoDir);
|
||||
}
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
repoRootDir = path.normalize(stdout.replace(/\n/g, ''));
|
||||
}
|
||||
|
||||
if (cb) {
|
||||
cb();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
ipcMain.on('unlock', (event, file) => {
|
||||
exec('git lfs unlock "' + file + '"', {
|
||||
maxBuffer: (1024 * 1024) * 10, //10MB
|
||||
cwd: repoDir
|
||||
},
|
||||
(error, stdout, stderr) => {
|
||||
let notification = {
|
||||
message: (error && error.message) || stderr,
|
||||
message: (error && error.message) || stderr,
|
||||
type: 'error'
|
||||
};
|
||||
|
||||
@@ -156,11 +238,12 @@ ipcMain.on('unlock', (event, file) => {
|
||||
|
||||
ipcMain.on('lock', (event, file) => {
|
||||
exec('git lfs lock --json "' + file + '"', {
|
||||
maxBuffer: (1024 * 1024) * 10, //10MB
|
||||
cwd: repoDir
|
||||
},
|
||||
(error, stdout, stderr) => {
|
||||
let notification = {
|
||||
message: (error && error.message) || stderr,
|
||||
message: (error && error.message) || stderr,
|
||||
type: 'error'
|
||||
};
|
||||
|
||||
@@ -177,10 +260,11 @@ ipcMain.on('lock', (event, file) => {
|
||||
});
|
||||
});
|
||||
|
||||
app.on('ready', createWindow);
|
||||
|
||||
app.on('window-all-closed', function() {
|
||||
if (process.platform != 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
ipcMain.on('restart', (event, newRepoDir) => {
|
||||
repoDir = newRepoDir;
|
||||
startup(loadRepoPage);
|
||||
});
|
||||
|
||||
app.on('ready', () => {
|
||||
startup(createWindow);
|
||||
});
|
||||
|
1332
app/package-lock.json
generated
1332
app/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"name": "gitlit-app",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "main.js",
|
||||
"dependencies": {
|
||||
"bootstrap": "^4.1.1",
|
||||
"ejs": "^2.6.1",
|
||||
"electron-in-page-search": "^1.3.2",
|
||||
"electron-localshortcut": "^3.1.0",
|
||||
"jquery": "^3.3.1",
|
||||
"minimist": "^1.2.0",
|
||||
"pnotify": "^4.0.0-alpha.4",
|
||||
"popper.js": "^1.14.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "^2.0.1"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "electron ."
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.e.tern.al/s2/gitlit"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
44
app/templates/files.ejs
Normal file
44
app/templates/files.ejs
Normal file
@@ -0,0 +1,44 @@
|
||||
<table class="table table-striped sortable js-filestable">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th>file</th>
|
||||
<th>status</th>
|
||||
<th class="sorttable_nosort">action</th>
|
||||
</tr>
|
||||
<thead>
|
||||
|
||||
<tbody>
|
||||
<% files.forEach((file) => { %>
|
||||
<tr>
|
||||
<td><%= file.file %></td>
|
||||
<td><%= file.lockedBy ? file.lockedBy + ' (id: ' + file.id + ')' : 'not locked' %></td>
|
||||
<td>
|
||||
<a class="btn btn-primary btn-sm js-lock"
|
||||
href="javascript:///"
|
||||
data-file="<%= file.file %>"
|
||||
style="<%= file.lockedBy ? 'display: none;' : '' %>"
|
||||
>
|
||||
Lock
|
||||
</a>
|
||||
<a class="btn btn-danger btn-sm js-unlock"
|
||||
href="javascript:///"
|
||||
data-file="<%= file.file %>"
|
||||
style="<%= file.lockedBy ? '' : 'display: none;' %>"
|
||||
>
|
||||
Unlock
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<% }); %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="float-right">
|
||||
<div style="display: inline;">
|
||||
<a class="btn btn-primary btn-sm js-open-folder" href="javascript:///">Open another folder</a>
|
||||
<input type="file" style="display: none" class="js-open-folder-input" webkitdirectory />
|
||||
</div>
|
||||
<a class="btn btn-secondary btn-sm js-refresh" href="javascript:///">
|
||||
Refresh
|
||||
</a>
|
||||
</div>
|
9
app/templates/firstRun.ejs
Normal file
9
app/templates/firstRun.ejs
Normal file
@@ -0,0 +1,9 @@
|
||||
<div class="jumbotron text-center">
|
||||
<img src="../logo/logo.png">
|
||||
<h1>gitlit</h1>
|
||||
<p class="lead">Handle git lfs locks with ease</p>
|
||||
<div class="text-center">
|
||||
<a class="btn btn-primary btn-lg js-open-folder" href="javascript:///">Open git repository folder</a>
|
||||
<input type="file" style="display: none" class="js-open-folder-input" webkitdirectory />
|
||||
</div>
|
||||
</div>
|
4
app/templates/isNoGitLfsRepo.ejs
Normal file
4
app/templates/isNoGitLfsRepo.ejs
Normal file
@@ -0,0 +1,4 @@
|
||||
<div class="alert alert-danger">
|
||||
<%= repoDir %> is not a git lfs repo.
|
||||
</div>
|
||||
<%- ejs.rr('templates/openFolder.ejs') %>
|
6
app/templates/main.ejs
Normal file
6
app/templates/main.ejs
Normal file
@@ -0,0 +1,6 @@
|
||||
<div class="alert alert-success js-repo-dir" style="display:none;"></div>
|
||||
<div class="files-table-container">
|
||||
<div class="alert alert-primary" role="alert">
|
||||
Getting file list...
|
||||
</div>
|
||||
</div>
|
4
app/templates/noGitLfsFiles.ejs
Normal file
4
app/templates/noGitLfsFiles.ejs
Normal file
@@ -0,0 +1,4 @@
|
||||
<div class="alert alert-info">
|
||||
no files tracked with lfs here.
|
||||
</div>
|
||||
<%- ejs.rr('templates/openFolder.ejs') %>
|
3
app/templates/openFolder.ejs
Normal file
3
app/templates/openFolder.ejs
Normal file
@@ -0,0 +1,3 @@
|
||||
<div class="text-center">
|
||||
<a class="btn btn-primary js-open-folder" href="javascript:///">Open another folder</a>
|
||||
</div>
|
BIN
build/icon.png
Normal file
BIN
build/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
BIN
logo/logo.png
Normal file
BIN
logo/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
BIN
logo/logo.xcf
Normal file
BIN
logo/logo.xcf
Normal file
Binary file not shown.
15
makedist.sh
15
makedist.sh
@@ -1,15 +0,0 @@
|
||||
#/bin/bash
|
||||
rm -rf dist
|
||||
mkdir dist
|
||||
node_modules/.bin/electron-packager ./app/ gitlit --all --out dist/
|
||||
|
||||
cd dist
|
||||
|
||||
for d in *; do
|
||||
if [[ -d "$d" ]]; then
|
||||
tar czf "$d.tgz" "$d"
|
||||
rm -rf "$d"
|
||||
fi
|
||||
done
|
||||
|
||||
cd ..
|
3190
package-lock.json
generated
3190
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
57
package.json
57
package.json
@@ -1,18 +1,59 @@
|
||||
{
|
||||
"name": "gitlit",
|
||||
"version": "1.0.0",
|
||||
"version": "2.0.7",
|
||||
"description": "",
|
||||
"main": "app/main.js",
|
||||
"build": {
|
||||
"appId": "s2.gitlit",
|
||||
"linux": {
|
||||
"target": [
|
||||
{
|
||||
"target": "tar.gz",
|
||||
"arch": [
|
||||
"x64"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"win": {
|
||||
"target": [
|
||||
{
|
||||
"target": "zip",
|
||||
"arch": [
|
||||
"x64"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"animate.css": "^3.5.2",
|
||||
"bootstrap": "^4.5.0",
|
||||
"ejs": "^3.1.3",
|
||||
"ejs-render-remote": "^1.0.13",
|
||||
"electron-find": "^1.0.6",
|
||||
"electron-localshortcut": "^3.2.1",
|
||||
"github-app-updater": "^1.0.4",
|
||||
"jquery": "^3.5.1",
|
||||
"material-design-icons": "^3.0.1",
|
||||
"minimist": "^1.2.5",
|
||||
"nonblockjs": "^1.0.8",
|
||||
"pnotify": "^4.0.1",
|
||||
"popper.js": "^1.16.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "^9.1.0",
|
||||
"electron-builder": "^22.7.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"start": "electron .",
|
||||
"pack": "electron-builder --linux --win portable nsis --dir --publish=never",
|
||||
"dist": "electron-builder --linux --win portable nsis --publish=never"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "ssh://git@git.e.tern.al:22022/s2/gitlit.git"
|
||||
"url": "https://github.com/S2-/gitlit"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"electron-packager": "^12.1.0"
|
||||
}
|
||||
"author": "s2",
|
||||
"license": "ISC"
|
||||
}
|
||||
|
Reference in New Issue
Block a user