Commit 84a0e65a authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@master

parent bf3d94a7
......@@ -5,7 +5,7 @@ import eventHub from '../../eventhub';
import service from '../../services';
import * as types from '../mutation_types';
import router from '../../ide_router';
import { setPageTitle, replaceFileUrl } from '../utils';
import { setPageTitle, replaceFileUrl, addFinalNewlineIfNeeded } from '../utils';
import { viewerTypes, stageKeys } from '../../constants';
export const closeFile = ({ commit, state, dispatch }, file) => {
......@@ -140,7 +140,10 @@ export const getRawFileData = ({ state, commit, dispatch, getters }, { path }) =
export const changeFileContent = ({ commit, dispatch, state }, { path, content }) => {
const file = state.entries[path];
commit(types.UPDATE_FILE_CONTENT, { path, content });
commit(types.UPDATE_FILE_CONTENT, {
path,
content: addFinalNewlineIfNeeded(content),
});
const indexOfChangedFile = state.changedFiles.findIndex(f => f.path === path);
......
......@@ -269,3 +269,7 @@ export const pathsAreEqual = (a, b) => {
return cleanA === cleanB;
};
// if the contents of a file dont end with a newline, this function adds a newline
export const addFinalNewlineIfNeeded = content =>
content.charAt(content.length - 1) !== '\n' ? `${content}\n` : content;
......@@ -160,24 +160,6 @@ function deferredInitialisation() {
});
loadAwardsHandler();
/**
* Toggle Canary Badge
*
* For GitLab.com only, when the user is using canary
* we render a Next badge and hide the option to switch
* to canay
*/
if (Cookies.get('gitlab_canary') && Cookies.get('gitlab_canary') === 'true') {
const canaryBadge = document.querySelector('.js-canary-badge');
const canaryLink = document.querySelector('.js-canary-link');
if (canaryBadge) {
canaryBadge.classList.remove('hidden');
}
if (canaryLink) {
canaryLink.classList.add('hidden');
}
}
}
document.addEventListener('DOMContentLoaded', () => {
......
......@@ -35,8 +35,8 @@
%li.d-md-none
= render 'shared/user_dropdown_contributing_link'
= render_if_exists 'shared/user_dropdown_instance_review'
- if Gitlab.com?
%li.js-canary-link.d-md-none
- if Gitlab.com_but_not_canary?
%li.d-md-none
= link_to _("Switch to GitLab Next"), "https://next.gitlab.com/"
- if current_user_menu?(:sign_out)
......
......@@ -18,8 +18,8 @@
- if logo_text.present?
%span.logo-text.d-none.d-lg-block.prepend-left-8
= logo_text
- if Gitlab.com?
= link_to 'https://next.gitlab.com', class: 'label-link js-canary-badge canary-badge bg-transparent hidden', target: :_blank do
- if Gitlab.com_and_canary?
= link_to 'https://next.gitlab.com', class: 'label-link canary-badge bg-transparent', target: :_blank do
%span.color-label.has-tooltip.badge.badge-pill.green-badge
= _('Next')
......
......@@ -12,6 +12,6 @@
%li
= render 'shared/user_dropdown_contributing_link'
= render_if_exists 'shared/user_dropdown_instance_review'
- if Gitlab.com?
%li.js-canary-link
- if Gitlab.com_but_not_canary?
%li
= link_to _("Switch to GitLab Next"), "https://next.gitlab.com/"
---
title: Fix canary badge and favicon inconsistency
merge_request: 19645
author:
type: fixed
---
title: 'Resolve: Web IDE does not create POSIX Compliant Files'
merge_request: 19339
author:
type: fixed
---
title: Use fingerprint when comparing security reports in MR widget
merge_request: 19654
author:
type: fixed
......@@ -339,3 +339,33 @@ questions that you know someone might ask.
Each scenario can be a third-level heading, e.g. `### Getting error message X`.
If you have none to add when creating a doc, leave this section in place
but commented out to help encourage others to add to it in the future. -->
## Troubleshooting
### Running out of memory
By default, ZAProxy, which DAST relies on, is allocated memory that sums to 25%
of the total memory on the host.
Since it keeps most of its information in memory during a scan,
it is possible for DAST to run out of memory while scanning large applications.
This results in the following error:
```
[zap.out] java.lang.OutOfMemoryError: Java heap space
```
Fortunately, it is straightforward to increase the amount of memory available
for DAST by overwriting the `script` key in the DAST template:
```yaml
include:
template: DAST.gitlab-ci.yml
dast:
script:
- export DAST_WEBSITE=${DAST_WEBSITE:-$(cat environment_url.txt)}
- /analyze -t $DAST_WEBSITE -z"-Xmx3072m"
```
Here, DAST is being allocated 3072 MB.
Change the number after `-Xmx` to the required memory amount.
......@@ -104,6 +104,7 @@ License Compliance can be configured using environment variables.
| Environment variable | Required | Description |
|-----------------------|----------|-------------|
| `MAVEN_CLI_OPTS` | no | Additional arguments for the mvn executable. If not supplied, defaults to `-DskipTests`. |
| `LICENSE_FINDER_CLI_OPTS` | no | Additional arguments for the `license_finder` executable. For example, if your project has both Golang and Ruby code stored in different directories and you want to only scan the Ruby code, you can update your `.gitlab-ci-yml` template to specify which project directories to scan, like `LICENSE_FINDER_CLI_OPTS: '--debug --aggregate-paths=. ruby'`. |
| `LM_JAVA_VERSION` | no | Version of Java. If set to `11`, Maven and Gradle use Java 11 instead of Java 8. |
| `LM_PYTHON_VERSION` | no | Version of Python. If set to `3`, dependencies are installed using Python 3 instead of Python 2.7. |
| `SETUP_CMD` | no | Custom setup for the dependency installation. (experimental) |
......
......@@ -47,6 +47,18 @@ module Gitlab
Gitlab.config.gitlab.url == COM_URL || gl_subdomain?
end
def self.canary?
Gitlab::Utils.to_boolean(ENV['CANARY'])
end
def self.com_and_canary?
com? && canary?
end
def self.com_but_not_canary?
com? && !canary?
end
def self.org?
Gitlab.config.gitlab.url == 'https://dev.gitlab.org'
end
......
......@@ -7,7 +7,7 @@ module Gitlab
image_name =
if appearance.favicon.exists?
appearance.favicon_path
elsif Gitlab::Utils.to_boolean(ENV['CANARY'])
elsif Gitlab.canary?
'favicon-yellow.png'
elsif Rails.env.development?
development_favicon
......
......@@ -261,10 +261,10 @@ describe('RepoEditor', () => {
});
it('updates state when model content changed', done => {
vm.model.setValue('testing 123');
vm.model.setValue('testing 123\n');
setTimeout(() => {
expect(vm.file.content).toBe('testing 123');
expect(vm.file.content).toBe('testing 123\n');
done();
});
......
......@@ -455,17 +455,33 @@ describe('IDE store file actions', () => {
beforeEach(() => {
tmpFile = file('tmpFile');
tmpFile.content = '\n';
tmpFile.raw = '\n';
store.state.entries[tmpFile.path] = tmpFile;
});
it('updates file content', done => {
store
.dispatch('changeFileContent', {
path: tmpFile.path,
content: 'content\n',
})
.then(() => {
expect(tmpFile.content).toBe('content\n');
done();
})
.catch(done.fail);
});
it('adds a newline to the end of the file if it doesnt already exist', done => {
store
.dispatch('changeFileContent', {
path: tmpFile.path,
content: 'content',
})
.then(() => {
expect(tmpFile.content).toBe('content');
expect(tmpFile.content).toBe('content\n');
done();
})
......@@ -510,12 +526,12 @@ describe('IDE store file actions', () => {
store
.dispatch('changeFileContent', {
path: tmpFile.path,
content: 'content',
content: 'content\n',
})
.then(() =>
store.dispatch('changeFileContent', {
path: tmpFile.path,
content: '',
content: '\n',
}),
)
.then(() => {
......
......@@ -292,6 +292,8 @@ describe('IDE commit module actions', () => {
type: 'blob',
active: true,
lastCommitSha: TEST_COMMIT_SHA,
content: '\n',
raw: '\n',
};
Object.assign(store.state, {
......@@ -359,7 +361,7 @@ describe('IDE commit module actions', () => {
{
action: commitActionTypes.update,
file_path: jasmine.anything(),
content: undefined,
content: '\n',
encoding: jasmine.anything(),
last_commit_id: undefined,
previous_path: undefined,
......@@ -386,7 +388,7 @@ describe('IDE commit module actions', () => {
{
action: commitActionTypes.update,
file_path: jasmine.anything(),
content: undefined,
content: '\n',
encoding: jasmine.anything(),
last_commit_id: TEST_COMMIT_SHA,
previous_path: undefined,
......
......@@ -597,4 +597,17 @@ describe('Multi-file store utils', () => {
});
});
});
describe('addFinalNewlineIfNeeded', () => {
it('adds a newline if it doesnt already exist', () => {
[
{ input: 'some text', output: 'some text\n' },
{ input: 'some text\n', output: 'some text\n' },
{ input: 'some text\n\n', output: 'some text\n\n' },
{ input: 'some\n text', output: 'some\n text\n' },
].forEach(({ input, output }) => {
expect(utils.addFinalNewlineIfNeeded(input)).toEqual(output);
});
});
});
});
......@@ -96,6 +96,48 @@ describe Gitlab do
end
end
describe '.canary?' do
it 'is true when CANARY env var is set to true' do
stub_env('CANARY', '1')
expect(described_class.canary?).to eq true
end
it 'is false when CANARY env var is set to false' do
stub_env('CANARY', '0')
expect(described_class.canary?).to eq false
end
end
describe '.com_and_canary?' do
it 'is true when on .com and canary' do
allow(described_class).to receive_messages(com?: true, canary?: true)
expect(described_class.com_and_canary?).to eq true
end
it 'is false when on .com but not on canary' do
allow(described_class).to receive_messages(com?: true, canary?: false)
expect(described_class.com_and_canary?).to eq false
end
end
describe '.com_but_not_canary?' do
it 'is false when on .com and canary' do
allow(described_class).to receive_messages(com?: true, canary?: true)
expect(described_class.com_but_not_canary?).to eq false
end
it 'is true when on .com but not on canary' do
allow(described_class).to receive_messages(com?: true, canary?: false)
expect(described_class.com_but_not_canary?).to eq true
end
end
describe '.dev_env_org_or_com?' do
it 'is true when on .com' do
allow(described_class).to receive_messages(com?: true, org?: false)
......
......@@ -995,10 +995,10 @@
resolved "https://registry.yarnpkg.com/@gitlab/svgs/-/svgs-1.80.0.tgz#52b2d25f002cdfe9bd7c366a043c1849687ad64b"
integrity sha512-hsyX3EZV/hk9bMTvvoxVcNC0EO6sy771BC2vXjqGtzjye4hTs0BTAzu3V0UPWuDompHtKXi/plVcJU+NxNLQ6Q==
"@gitlab/ui@7.3.0":
version "7.3.0"
resolved "https://registry.yarnpkg.com/@gitlab/ui/-/ui-7.3.0.tgz#9ed6d2144cb999c12675b309ecda3279c4b88bf6"
integrity sha512-QMn84x7DrjDOCKD1/Exh26wwkAvdAjlIWjafvISTHZ+PAWY6XxEAYyjllM5k0fQpNZP3sw7sBWWYvezDVdLnmw==
"@gitlab/ui@7.5.0":
version "7.5.0"
resolved "https://registry.yarnpkg.com/@gitlab/ui/-/ui-7.5.0.tgz#d25567157d20bb64741ab51b6b9f770ea49e634d"
integrity sha512-h7RxNMtQ1+KHK2uV+nb5d7UlqBVOtj9VGXqRXqVinc1b1x0onnvFFnYjgxf7XbXdsZq85ZyTlZa1SkduRig+Eg==
dependencies:
"@babel/standalone" "^7.0.0"
"@gitlab/vue-toasted" "^1.2.1"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment