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
8f3a6ed9
Commit
8f3a6ed9
authored
Apr 29, 2017
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: Use current user as commit author
parent
1765c9c6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
2 deletions
+13
-2
security.js
server/helpers/security.js
+9
-1
git.js
server/libs/git.js
+4
-1
No files found.
server/helpers/security.js
View file @
8f3a6ed9
'use strict'
/* global appdata, appconfig */
const
_
=
require
(
'lodash'
)
module
.
exports
=
{
sanitizeCommitUser
(
user
)
{
let
wlist
=
new
RegExp
(
'(?!([^a-zA-Z0-9-_.
\'
,& ]|'
+
appdata
.
regex
.
cjk
.
source
+
'))'
,
'g'
)
return
{
name
:
_
.
chain
(
user
.
name
).
replace
(
wlist
,
''
).
trim
().
value
(),
email
:
appconfig
.
git
.
showUserEmail
?
user
.
email
:
appconfig
.
git
.
serverEmail
}
}
}
server/libs/git.js
View file @
8f3a6ed9
...
...
@@ -7,6 +7,8 @@ const fs = Promise.promisifyAll(require('fs'))
const
_
=
require
(
'lodash'
)
const
URL
=
require
(
'url'
)
const
securityHelper
=
require
(
'../helpers/security'
)
/**
* Git Model
*/
...
...
@@ -207,7 +209,8 @@ module.exports = {
commitMsg
=
(
isTracked
)
?
'Updated '
+
gitFilePath
:
'Added '
+
gitFilePath
return
self
.
_git
.
add
(
gitFilePath
)
}).
then
(()
=>
{
return
self
.
_git
.
exec
(
'commit'
,
[
'-m'
,
commitMsg
,
'--author="'
+
author
.
name
+
' <'
+
author
.
email
+
'>"'
]).
catch
((
err
)
=>
{
let
commitUsr
=
securityHelper
.
sanitizeCommitUser
(
author
)
return
self
.
_git
.
exec
(
'commit'
,
[
'-m'
,
commitMsg
,
'--author="'
+
commitUsr
.
name
+
' <'
+
commitUsr
.
email
+
'>"'
]).
catch
((
err
)
=>
{
if
(
_
.
includes
(
err
.
stdout
,
'nothing to commit'
))
{
return
true
}
})
})
...
...
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