Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
fa04b50b
Commit
fa04b50b
authored
May 19, 2017
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Read HEAD commit and use as releases value
parent
9d29eb7e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
19 deletions
+51
-19
app/assets/javascripts/raven/index.js
app/assets/javascripts/raven/index.js
+4
-0
app/assets/javascripts/raven/raven_config.js
app/assets/javascripts/raven/raven_config.js
+2
-0
config/webpack.config.js
config/webpack.config.js
+28
-1
spec/javascripts/raven/index_spec.js
spec/javascripts/raven/index_spec.js
+10
-9
spec/javascripts/raven/raven_config_spec.js
spec/javascripts/raven/raven_config_spec.js
+7
-9
No files found.
app/assets/javascripts/raven/index.js
View file @
fa04b50b
...
@@ -6,6 +6,10 @@ const index = function index() {
...
@@ -6,6 +6,10 @@ const index = function index() {
currentUserId
:
gon
.
current_user_id
,
currentUserId
:
gon
.
current_user_id
,
whitelistUrls
:
[
gon
.
gitlab_url
],
whitelistUrls
:
[
gon
.
gitlab_url
],
isProduction
:
process
.
env
.
NODE_ENV
,
isProduction
:
process
.
env
.
NODE_ENV
,
release
:
process
.
env
.
HEAD_COMMIT_SHA
,
tags
:
{
HEAD_COMMIT_SHA
:
process
.
env
.
HEAD_COMMIT_SHA
,
},
});
});
return
RavenConfig
;
return
RavenConfig
;
...
...
app/assets/javascripts/raven/raven_config.js
View file @
fa04b50b
...
@@ -57,6 +57,8 @@ const RavenConfig = {
...
@@ -57,6 +57,8 @@ const RavenConfig = {
configure
()
{
configure
()
{
Raven
.
config
(
this
.
options
.
sentryDsn
,
{
Raven
.
config
(
this
.
options
.
sentryDsn
,
{
release
:
this
.
options
.
release
,
tags
:
this
.
options
.
tags
,
whitelistUrls
:
this
.
options
.
whitelistUrls
,
whitelistUrls
:
this
.
options
.
whitelistUrls
,
environment
:
this
.
options
.
isProduction
?
'
production
'
:
'
development
'
,
environment
:
this
.
options
.
isProduction
?
'
production
'
:
'
development
'
,
ignoreErrors
:
this
.
IGNORE_ERRORS
,
ignoreErrors
:
this
.
IGNORE_ERRORS
,
...
...
config/webpack.config.js
View file @
fa04b50b
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
var
fs
=
require
(
'
fs
'
);
var
fs
=
require
(
'
fs
'
);
var
path
=
require
(
'
path
'
);
var
path
=
require
(
'
path
'
);
var
execSync
=
require
(
'
child_process
'
).
execSync
;
var
webpack
=
require
(
'
webpack
'
);
var
webpack
=
require
(
'
webpack
'
);
var
StatsPlugin
=
require
(
'
stats-webpack-plugin
'
);
var
StatsPlugin
=
require
(
'
stats-webpack-plugin
'
);
var
CompressionPlugin
=
require
(
'
compression-webpack-plugin
'
);
var
CompressionPlugin
=
require
(
'
compression-webpack-plugin
'
);
...
@@ -197,7 +198,33 @@ var config = {
...
@@ -197,7 +198,33 @@ var config = {
}
}
}
}
function
getHeadCommitSHA
()
{
// Simple SHA validation.
// Match 5-40 numbers or lowercase letters between a and f.
const
SHA_REGEX
=
/^
\b[
0-9a-f
]{5,40}\b
$/
;
let
stdout
;
try
{
stdout
=
execSync
(
'
git rev-parse HEAD
'
);
}
catch
(
error
)
{
throw
error
;
}
const
headCommitSHA
=
stdout
.
trim
();
if
(
!
SHA_REGEX
.
test
(
headCommitSHA
))
{
throw
new
Error
(
`\`git rev-parse HEAD\` output is not a valid SHA1:
${
headCommitSHA
}
`
);
}
return
headCommitSHA
;
}
if
(
IS_PRODUCTION
)
{
if
(
IS_PRODUCTION
)
{
const
processEnv
=
{
NODE_ENV
:
JSON
.
stringify
(
'
production
'
),
};
processEnv
.
HEAD_COMMIT_SHA
=
getHeadCommitSHA
();
config
.
devtool
=
'
source-map
'
;
config
.
devtool
=
'
source-map
'
;
config
.
plugins
.
push
(
config
.
plugins
.
push
(
new
webpack
.
NoEmitOnErrorsPlugin
(),
new
webpack
.
NoEmitOnErrorsPlugin
(),
...
@@ -209,7 +236,7 @@ if (IS_PRODUCTION) {
...
@@ -209,7 +236,7 @@ if (IS_PRODUCTION) {
sourceMap
:
true
sourceMap
:
true
}),
}),
new
webpack
.
DefinePlugin
({
new
webpack
.
DefinePlugin
({
'
process.env
'
:
{
NODE_ENV
:
JSON
.
stringify
(
'
production
'
)
}
'
process.env
'
:
processEnv
,
}),
}),
new
CompressionPlugin
({
new
CompressionPlugin
({
asset
:
'
[path].gz[query]
'
,
asset
:
'
[path].gz[query]
'
,
...
...
spec/javascripts/raven/index_spec.js
View file @
fa04b50b
...
@@ -2,18 +2,14 @@ import RavenConfig from '~/raven/raven_config';
...
@@ -2,18 +2,14 @@ import RavenConfig from '~/raven/raven_config';
import
index
from
'
~/raven/index
'
;
import
index
from
'
~/raven/index
'
;
describe
(
'
RavenConfig options
'
,
()
=>
{
describe
(
'
RavenConfig options
'
,
()
=>
{
let
sentryDsn
;
const
sentryDsn
=
'
sentryDsn
'
;
let
currentUserId
;
const
currentUserId
=
'
currentUserId
'
;
let
gitlabUrl
;
const
gitlabUrl
=
'
gitlabUrl
'
;
let
isProduction
;
const
isProduction
=
'
isProduction
'
;
const
headCommitSHA
=
'
headCommitSHA
'
;
let
indexReturnValue
;
let
indexReturnValue
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
sentryDsn
=
'
sentryDsn
'
;
currentUserId
=
'
currentUserId
'
;
gitlabUrl
=
'
gitlabUrl
'
;
isProduction
=
'
isProduction
'
;
window
.
gon
=
{
window
.
gon
=
{
sentry_dsn
:
sentryDsn
,
sentry_dsn
:
sentryDsn
,
current_user_id
:
currentUserId
,
current_user_id
:
currentUserId
,
...
@@ -21,6 +17,7 @@ describe('RavenConfig options', () => {
...
@@ -21,6 +17,7 @@ describe('RavenConfig options', () => {
};
};
process
.
env
.
NODE_ENV
=
isProduction
;
process
.
env
.
NODE_ENV
=
isProduction
;
process
.
env
.
HEAD_COMMIT_SHA
=
headCommitSHA
;
spyOn
(
RavenConfig
,
'
init
'
);
spyOn
(
RavenConfig
,
'
init
'
);
...
@@ -33,6 +30,10 @@ describe('RavenConfig options', () => {
...
@@ -33,6 +30,10 @@ describe('RavenConfig options', () => {
currentUserId
,
currentUserId
,
whitelistUrls
:
[
gitlabUrl
],
whitelistUrls
:
[
gitlabUrl
],
isProduction
,
isProduction
,
release
:
headCommitSHA
,
tags
:
{
HEAD_COMMIT_SHA
:
headCommitSHA
,
},
});
});
});
});
...
...
spec/javascripts/raven/raven_config_spec.js
View file @
fa04b50b
...
@@ -25,17 +25,9 @@ describe('RavenConfig', () => {
...
@@ -25,17 +25,9 @@ describe('RavenConfig', () => {
});
});
describe
(
'
init
'
,
()
=>
{
describe
(
'
init
'
,
()
=>
{
let
options
;
const
options
=
{}
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
options
=
{
sentryDsn
:
'
//sentryDsn
'
,
ravenAssetUrl
:
'
//ravenAssetUrl
'
,
currentUserId
:
1
,
whitelistUrls
:
[
'
//gitlabUrl
'
],
isProduction
:
true
,
};
spyOn
(
RavenConfig
,
'
configure
'
);
spyOn
(
RavenConfig
,
'
configure
'
);
spyOn
(
RavenConfig
,
'
bindRavenErrors
'
);
spyOn
(
RavenConfig
,
'
bindRavenErrors
'
);
spyOn
(
RavenConfig
,
'
setUser
'
);
spyOn
(
RavenConfig
,
'
setUser
'
);
...
@@ -84,6 +76,10 @@ describe('RavenConfig', () => {
...
@@ -84,6 +76,10 @@ describe('RavenConfig', () => {
sentryDsn
:
'
//sentryDsn
'
,
sentryDsn
:
'
//sentryDsn
'
,
whitelistUrls
:
[
'
//gitlabUrl
'
],
whitelistUrls
:
[
'
//gitlabUrl
'
],
isProduction
:
true
,
isProduction
:
true
,
release
:
'
release
'
,
tags
:
{
HEAD_COMMIT_SHA
:
'
headCommitSha
'
,
},
};
};
ravenConfig
=
jasmine
.
createSpyObj
(
'
ravenConfig
'
,
[
'
shouldSendSample
'
]);
ravenConfig
=
jasmine
.
createSpyObj
(
'
ravenConfig
'
,
[
'
shouldSendSample
'
]);
...
@@ -100,6 +96,8 @@ describe('RavenConfig', () => {
...
@@ -100,6 +96,8 @@ describe('RavenConfig', () => {
it
(
'
should call Raven.config
'
,
()
=>
{
it
(
'
should call Raven.config
'
,
()
=>
{
expect
(
Raven
.
config
).
toHaveBeenCalledWith
(
options
.
sentryDsn
,
{
expect
(
Raven
.
config
).
toHaveBeenCalledWith
(
options
.
sentryDsn
,
{
release
:
options
.
release
,
tags
:
options
.
tags
,
whitelistUrls
:
options
.
whitelistUrls
,
whitelistUrls
:
options
.
whitelistUrls
,
environment
:
'
production
'
,
environment
:
'
production
'
,
ignoreErrors
:
ravenConfig
.
IGNORE_ERRORS
,
ignoreErrors
:
ravenConfig
.
IGNORE_ERRORS
,
...
...
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