Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
cc1e6b44
Commit
cc1e6b44
authored
Aug 25, 2016
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Git commit handling
parent
32c50eea
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
8 deletions
+64
-8
git.js
models/git.js
+56
-8
server.js
server.js
+8
-0
No files found.
models/git.js
View file @
cc1e6b44
...
...
@@ -5,6 +5,7 @@ var NodeGit = require("nodegit"),
path
=
require
(
'path'
),
os
=
require
(
'os'
),
fs
=
Promise
.
promisifyAll
(
require
(
"fs"
)),
moment
=
require
(
'moment'
),
_
=
require
(
'lodash'
);
/**
...
...
@@ -20,6 +21,10 @@ module.exports = {
inst
:
null
,
sync
:
true
},
_signature
:
{
name
:
'Wiki'
,
email
:
'user@example.com'
},
_opts
:
{
clone
:
{},
push
:
{}
...
...
@@ -54,6 +59,11 @@ module.exports = {
});
// Define signature
self
.
_signature
.
name
=
appconfig
.
git
.
userinfo
.
name
||
'Wiki'
;
self
.
_signature
.
email
=
appconfig
.
git
.
userinfo
.
email
||
'user@example.com'
;
return
self
;
},
...
...
@@ -166,9 +176,12 @@ module.exports = {
let
remoteCallbacks
=
new
NodeGit
.
RemoteCallbacks
();
let
credFunc
=
this
.
_generateCredentials
(
appconfig
);
remoteCallbacks
.
credentials
=
()
=>
{
return
credFunc
;
};
remoteCallbacks
.
transferProgress
=
_
.
noop
;
if
(
os
.
type
()
===
'Darwin'
)
{
remoteCallbacks
.
certificateCheck
=
()
=>
{
return
1
;
};
// Bug in OS X, bypass certs check workaround
}
else
{
remoteCallbacks
.
certificateCheck
=
_
.
noop
;
}
return
remoteCallbacks
;
...
...
@@ -232,14 +245,49 @@ module.exports = {
.
then
(()
=>
{
return
self
.
_repo
.
inst
.
getRemote
(
'origin'
).
then
((
remote
)
=>
{
self
.
_repo
.
inst
.
getStatus
().
then
(
function
(
arrayStatusFile
)
{
console
.
log
(
arrayStatusFile
[
0
].
status
());
});
/*remote.push( ["refs/heads/master:refs/heads/master"], self._opts.push ).then((errNum) => {
console.log('DUDE' + errNum);
}).catch((err) => {
console.log(err);
});*/
// Get modified files
return
self
.
_repo
.
inst
.
refreshIndex
().
then
((
index
)
=>
{
return
self
.
_repo
.
inst
.
getStatus
().
then
(
function
(
arrayStatusFile
)
{
let
addOp
=
[];
// Add to next commit
_
.
forEach
(
arrayStatusFile
,
(
v
)
=>
{
addOp
.
push
(
arrayStatusFile
[
0
].
path
());
});
console
.
log
(
'DUDE1'
);
// Create Commit
let
sig
=
NodeGit
.
Signature
.
create
(
self
.
_signature
.
name
,
self
.
_signature
.
email
,
moment
().
utc
().
unix
(),
0
);
return
self
.
_repo
.
inst
.
createCommitOnHead
(
addOp
,
sig
,
sig
,
"Wiki Sync"
).
then
(()
=>
{
console
.
log
(
'DUDE2'
);
return
remote
.
connect
(
NodeGit
.
Enums
.
DIRECTION
.
PUSH
,
self
.
_opts
.
push
.
callbacks
).
then
(()
=>
{
console
.
log
(
'DUDE3'
);
// Push to remote
return
remote
.
push
(
[
"refs/heads/master:refs/heads/master"
],
self
.
_opts
.
push
).
then
((
errNum
)
=>
{
console
.
log
(
'DUDE'
+
errNum
);
}).
catch
((
err
)
=>
{
console
.
log
(
err
);
});
});
});
});
})
/**/
});
}).
catch
((
err
)
=>
{
winston
.
error
(
'Unable to push to git origin!'
+
err
);
...
...
server.js
View file @
cc1e6b44
...
...
@@ -4,6 +4,14 @@
// Licensed under AGPLv3
// ===========================================
process
.
on
(
'uncaughtException'
,
function
(
exception
)
{
console
.
log
(
exception
);
});
process
.
on
(
'unhandledRejection'
,
(
reason
,
p
)
=>
{
console
.
log
(
"Unhandled Rejection at: Promise "
,
p
,
" reason: "
,
reason
);
// application specific logging, throwing an error, or other logic here
});
global
.
ROOTPATH
=
__dirname
;
// ----------------------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment