diff options
-rw-r--r-- | CHANGELOG | 3 | ||||
-rw-r--r-- | app/assets/stylesheets/base/mixins.scss | 4 | ||||
-rw-r--r-- | app/assets/stylesheets/pages/projects.scss | 9 | ||||
-rw-r--r-- | app/helpers/diff_helper.rb | 19 | ||||
-rw-r--r-- | app/helpers/events_helper.rb | 12 | ||||
-rw-r--r-- | app/services/git_push_service.rb | 4 | ||||
-rw-r--r-- | app/views/projects/diffs/_diffs.html.haml | 8 | ||||
-rw-r--r-- | app/views/projects/diffs/_warning.html.haml | 2 | ||||
-rw-r--r-- | app/views/shared/_clone_panel.html.haml | 34 | ||||
-rw-r--r-- | doc/install/installation.md | 6 | ||||
-rw-r--r-- | doc/release/master.md | 29 | ||||
-rw-r--r-- | doc/release/patch.md | 3 | ||||
-rw-r--r-- | doc/update/upgrader.md | 2 | ||||
-rw-r--r-- | docker/README.md | 20 | ||||
-rw-r--r-- | docker/single/marathon.json | 19 | ||||
-rw-r--r-- | spec/helpers/diff_helper_spec.rb | 54 | ||||
-rw-r--r-- | spec/services/git_push_service_spec.rb | 15 |
17 files changed, 181 insertions, 62 deletions
diff --git a/CHANGELOG b/CHANGELOG index fadf46209b5..b03f1efa990 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ Please view this file on the master branch, on stable branches it's out of date. v 7.11.0 (unreleased) + - Make the first branch pushed to an empty repository the default HEAD (Stan Hu) - Make Reply-To config apply to change e-mail confirmation and other Devise notifications (Stan Hu) - Add application setting to restrict user signups to e-mail domains (Stan Hu) - Don't allow a merge request to be merged when its title starts with "WIP". @@ -21,6 +22,8 @@ v 7.11.0 (unreleased) - Fix bug causing `@whatever` inside an issue's first code block to be picked up as a user mention. - Fix bug causing `@whatever` inside an inline code snippet (backtick-style) to be picked up as a user mention. - When use change branches link at MR form - save source branch selection instead of target one + - Improve handling of large diffs + - - Show Atom feed buttons everywhere where applicable. - Add project activity atom feed. - Don't crash when an MR from a fork has a cross-reference comment from the target project on one of its commits. diff --git a/app/assets/stylesheets/base/mixins.scss b/app/assets/stylesheets/base/mixins.scss index b8b163a42b2..a0794e7825a 100644 --- a/app/assets/stylesheets/base/mixins.scss +++ b/app/assets/stylesheets/base/mixins.scss @@ -21,6 +21,10 @@ @include border-radius($radius 0 0 $radius) } +@mixin border-radius-right($radius) { + @include border-radius(0 0 $radius $radius) +} + @mixin linear-gradient($from, $to) { background-image: -webkit-gradient(linear, 0 0, 0 100%, from($from), to($to)); background-image: -webkit-linear-gradient($from, $to); diff --git a/app/assets/stylesheets/pages/projects.scss b/app/assets/stylesheets/pages/projects.scss index e6a4bc62c58..5a8d4665294 100644 --- a/app/assets/stylesheets/pages/projects.scss +++ b/app/assets/stylesheets/pages/projects.scss @@ -102,6 +102,15 @@ .input-group-addon { background: #FAFAFA; + + &.git-protocols { + padding: 0; + border: none; + + .input-group-btn:last-child > .btn { + @include border-radius-right(0); + } + } } } diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb index 162778ade58..1b10795bb7b 100644 --- a/app/helpers/diff_helper.rb +++ b/app/helpers/diff_helper.rb @@ -7,14 +7,23 @@ module DiffHelper end end - def safe_diff_files(diffs) - diffs.first(allowed_diff_size).map do |diff| - Gitlab::Diff::File.new(diff) + def allowed_diff_lines + if diff_hard_limit_enabled? + Commit::DIFF_HARD_LIMIT_LINES + else + Commit::DIFF_SAFE_LINES end end - def show_diff_size_warning?(diffs) - diffs.size > allowed_diff_size + def safe_diff_files(diffs) + lines = 0 + safe_files = [] + diffs.first(allowed_diff_size).each do |diff| + lines += diff.diff.lines.count + break if lines > allowed_diff_lines + safe_files << Gitlab::Diff::File.new(diff) + end + safe_files end def diff_hard_limit_enabled? diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index c9fd0f0362b..18c75a8726b 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -25,12 +25,16 @@ module EventsHelper def event_filter_link(key, tooltip) key = key.to_s - active = if @event_filter.active? key - 'active' - end + active = 'active' if @event_filter.active?(key) + link_opts = { + class: 'event_filter_link', + id: "#{key}_event_filter", + title: "Filter by #{tooltip.downcase}", + data: { toggle: 'tooltip', placement: 'top' } + } content_tag :li, class: "filter_icon #{active}" do - link_to request.path, class: 'has_tooltip event_filter_link', id: "#{key}_event_filter", 'data-original-title' => 'Filter by ' + tooltip.downcase do + link_to request.path, link_opts do icon(icon_for_event[key]) + content_tag(:span, ' ' + tooltip) end end diff --git a/app/services/git_push_service.rb b/app/services/git_push_service.rb index 1b889e0da8b..bdf36af02fd 100644 --- a/app/services/git_push_service.rb +++ b/app/services/git_push_service.rb @@ -31,6 +31,10 @@ class GitPushService # Initial push to the default branch. Take the full history of that branch as "newly pushed". @push_commits = project.repository.commits(newrev) + # Ensure HEAD points to the default branch in case it is not master + branch_name = Gitlab::Git.ref_name(ref) + project.change_head(branch_name) + # Set protection on the default branch if configured if (current_application_settings.default_branch_protection != PROTECTION_NONE) developers_can_push = current_application_settings.default_branch_protection == PROTECTION_DEV_CAN_PUSH ? true : false diff --git a/app/views/projects/diffs/_diffs.html.haml b/app/views/projects/diffs/_diffs.html.haml index b49aee504fe..ec8974c5475 100644 --- a/app/views/projects/diffs/_diffs.html.haml +++ b/app/views/projects/diffs/_diffs.html.haml @@ -5,11 +5,13 @@ = parallel_diff_btn = render 'projects/diffs/stats', diffs: diffs -- if show_diff_size_warning?(diffs) - = render 'projects/diffs/warning', diffs: diffs +- diff_files = safe_diff_files(diffs) + +- if diff_files.count < diffs.size + = render 'projects/diffs/warning', diffs: diffs, shown_files_count: diff_files.count .files - - safe_diff_files(diffs).each_with_index do |diff_file, index| + - diff_files.each_with_index do |diff_file, index| = render 'projects/diffs/file', diff_file: diff_file, i: index, project: project - if @diff_timeout diff --git a/app/views/projects/diffs/_warning.html.haml b/app/views/projects/diffs/_warning.html.haml index 47abbba2eb2..bd0b7376ba7 100644 --- a/app/views/projects/diffs/_warning.html.haml +++ b/app/views/projects/diffs/_warning.html.haml @@ -14,6 +14,6 @@ = link_to "Email patch", merge_request_path(@merge_request, format: :patch), class: "btn btn-warning btn-sm" %p To preserve performance only - %strong #{allowed_diff_size} of #{diffs.size} + %strong #{shown_files_count} of #{diffs.size} files are displayed. diff --git a/app/views/shared/_clone_panel.html.haml b/app/views/shared/_clone_panel.html.haml index aaab0d35f59..60bb76e898a 100644 --- a/app/views/shared/_clone_panel.html.haml +++ b/app/views/shared/_clone_panel.html.haml @@ -1,22 +1,22 @@ - project = project || @project .git-clone-holder.input-group - .input-group-btn - %button{ | - :type => 'button', | - class: "btn btn-sm #{ 'active' if default_clone_protocol == 'ssh' }#{ ' has_tooltip' if current_user && current_user.require_ssh_key? }", | - :"data-clone" => project.ssh_url_to_repo, | - :"data-title" => "Add an SSH key to your profile<br> to pull or push via SSH", - :"data-html" => "true", - :"data-container" => "body"} - SSH - %button{ | - :type => 'button', | - class: "btn btn-sm #{ 'active' if default_clone_protocol == 'http' }#{ ' has_tooltip' if current_user && current_user.require_password? }", | - :"data-clone" => project.http_url_to_repo, | - :"data-title" => "Set a password on your account<br> to pull or push via #{gitlab_config.protocol.upcase}", - :"data-html" => "true", - :"data-container" => "body"} - = gitlab_config.protocol.upcase + .input-group-addon.git-protocols + .input-group-btn + %button{ | + class: "btn btn-sm #{ 'active' if default_clone_protocol == 'ssh' }#{ ' has_tooltip' if current_user && current_user.require_ssh_key? }", | + :"data-clone" => project.ssh_url_to_repo, | + :"data-title" => "Add an SSH key to your profile<br> to pull or push via SSH", + :"data-html" => "true", + :"data-container" => "body"} + SSH + .input-group-btn + %button{ | + class: "btn btn-sm #{ 'active' if default_clone_protocol == 'http' }#{ ' has_tooltip' if current_user && current_user.require_password? }", | + :"data-clone" => project.http_url_to_repo, | + :"data-title" => "Set a password on your account<br> to pull or push via #{gitlab_config.protocol.upcase}", + :"data-html" => "true", + :"data-container" => "body"} + = gitlab_config.protocol.upcase = text_field_tag :project_clone, default_url_to_repo(project), class: "js-select-on-focus form-control input-sm", readonly: true - if project.kind_of?(Project) .input-group-addon diff --git a/doc/install/installation.md b/doc/install/installation.md index a61a40ebd16..ca25eaea799 100644 --- a/doc/install/installation.md +++ b/doc/install/installation.md @@ -4,6 +4,12 @@ Since an installation from source is a lot of work and error prone we strongly recommend the fast and reliable [Omnibus package installation](https://about.gitlab.com/downloads/) (deb/rpm). +One reason the Omnibus package is more reliable is its use of Runit to restart any of the GitLab processes in case one crashes. +On heavily used GitLab instances the memory usage of the Sidekiq background worker will grow over time. +Omnibus packages solve this by [letting the Sidekiq terminate gracefully](http://doc.gitlab.com/ce/operations/sidekiq_memory_killer.html) if it uses too much memory. +After this termination Runit will detect Sidekiq is not running and will start it. +Since installations from source don't have Runit, Sidekiq can't be terminated and its memory usage will grow over time. + ## Select Version to Install Make sure you view [this installation guide](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/install/installation.md) from the tag (version) of GitLab you would like to install. diff --git a/doc/release/master.md b/doc/release/master.md index 19070b46a0d..9163e652003 100644 --- a/doc/release/master.md +++ b/doc/release/master.md @@ -31,3 +31,32 @@ git remote add gl git@gitlab.com:gitlab-org/gitlab-ce.git gpa ``` +# Yanking packages from packages.gitlab.com + +In case something went wrong with the release and there is a need to remove the packages you can yank the packages by following the +procedure described in [package cloud documentation](https://packagecloud.io/docs#yank_pkg). + +You need to have: + +1. `package_cloud` gem installed (sudo gem install package_cloud) +1. Email and password for packages.gitlab.com +1. Make sure that you are supplying the url to packages.gitlab.com (default is packagecloud.io) + +Example of yanking a package: + +```bash +package_cloud yank --url https://packages.gitlab.com gitlab/gitlab-ce/el/6 gitlab-ce-7.10.2~omnibus-1.x86_64.rpm +``` + +If you are attempting this for the first time the output will look something like: + +```bash +Looking for repository at gitlab/gitlab-ce... No config file exists at /Users/marin/.packagecloud. Login to create one. +Email: +marin@gitlab.com +Password: + +Got your token. Writing a config file to /Users/marin/.packagecloud... success! +success! +Attempting to yank package at gitlab/gitlab-ce/el/6/gitlab-ce-7.10.2~omnibus-1.x86_64.rpm...done! +``` diff --git a/doc/release/patch.md b/doc/release/patch.md index 4c7b471785f..a569bb3da8d 100644 --- a/doc/release/patch.md +++ b/doc/release/patch.md @@ -44,7 +44,7 @@ Create release tag and push to remotes: bundle exec rake release["x.x.x"] ``` -### Release +## Release 1. [Build new packages with the latest version](https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/release.md) 1. Apply the patch to GitLab.com and the private GitLab development server @@ -53,3 +53,4 @@ bundle exec rake release["x.x.x"] 1. Send tweets about the release from `@gitlab`, tweet should include the most important feature that the release is addressing and link to the blog post 1. Note in the 'GitLab X.X regressions' issue that the patch was published (CE only) 1. [Create new AMIs](https://dev.gitlab.org/gitlab/AMI/blob/master/README.md) +1. Create a new patch release issue for the next potential release
\ No newline at end of file diff --git a/doc/update/upgrader.md b/doc/update/upgrader.md index 2cca46c86a3..d23534d58b6 100644 --- a/doc/update/upgrader.md +++ b/doc/update/upgrader.md @@ -73,4 +73,4 @@ cd /home/git/gitlab; \ sudo service gitlab start; \ sudo service nginx restart; \ sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production -``` +```
\ No newline at end of file diff --git a/docker/README.md b/docker/README.md index 5561e562637..2e533ae9dd5 100644 --- a/docker/README.md +++ b/docker/README.md @@ -11,7 +11,7 @@ After starting a container you can go to [http://localhost:8080/](http://localho It might take a while before the docker container is responding to queries. -You can check the status with `sudo docker logs -f gitlab-ce`. +You can check the status with something like `sudo docker logs -f 7c10172d7705`. You can login to the web interface with username `root` and password `5iveL!fe`. @@ -43,27 +43,27 @@ sudo docker pull sytse/gitlab-ce:7.10.1 Run the image: ```bash -sudo docker run --detach --name gitlab-ce --publish 8080:80 --publish 2222:22 gitlab-ce +sudo docker run --detach --publish 8080:80 --publish 2222:22 sytse/gitlab-ce:7.10.1 ``` -After this you can login to the web interface as explained in 'After starting a container' +After this you can login to the web interface as explained above in 'After starting a container'. Build the image: ```bash -sudo docker build --tag gitlab-ce docker/single/ +sudo docker build --tag sytse/gitlab-ce:7.10.1 docker/single/ ``` Publish the image to Dockerhub: ```bash -sudo docker commit -m "Initial commit" -a "Sytse Sijbrandij" gitlab-ce sytse/gitlab-ce:7.10.1 -sudo docker push sytse/gitlab-ce:7.10.1 +sudo docker push sytse/gitlab-ce ``` -Troubleshoot: +Diagnosing commands: ```bash +sudo docker run -i -t sytse/gitlab-ce:7.10.1 sudo docker run -ti -e TERM=linux --name gitlab-ce-troubleshoot --publish 8080:80 --publish 2222:22 sytse/gitlab-ce:7.10.1 bash /usr/local/bin/wrapper ``` @@ -83,7 +83,7 @@ sudo docker run --name gitlab-data sytse/gitlab-data /bin/true sudo docker run --detach --name gitlab_app --publish 8080:80 --publish 2222:22 --volumes-from gitlab_data sytse/gitlab-app:7.10.1 ``` -Now please refer to the section above 'After starting a container'. +After this you can login to the web interface as explained above in 'After starting a container'. ### Build images @@ -94,7 +94,7 @@ sudo docker build --tag gitlab-data docker/data/ sudo docker build --tag gitlab-app:7.10.1 docker/app/ ``` -After this run the images as described in the prepivous section. +After this run the images as described in the previous section. We assume using a data volume container, this will simplify migrations and backups. This empty container will exist to persist as volumes the 3 directories used by GitLab, so remember not to delete it. @@ -152,4 +152,4 @@ sudo docker push sytse/gitlab_data ## Troubleshooting -Please see the [troubleshooting](troubleshooting.md) file in this directory. +Please see the [troubleshooting](troubleshooting.md) file in this directory.
\ No newline at end of file diff --git a/docker/single/marathon.json b/docker/single/marathon.json index b22b9f6274f..d23c2b84e0e 100644 --- a/docker/single/marathon.json +++ b/docker/single/marathon.json @@ -9,23 +9,6 @@ "docker": { "network": "HOST", "image": "sytse/gitlab-ce:7.10.1" - }, - "volumes": [ - { - "containerPath": "/var/opt/gitlab", - "hostPath": "/var/opt/gitlab", - "mode": "RW" - }, - { - "containerPath": "/var/log/gitlab", - "hostPath": "/var/log/gitlab", - "mode": "RW" - }, - { - "containerPath": "/etc/gitlab", - "hostPath": "/etc/gitlab", - "mode": "RW" - } - ] + } } }
\ No newline at end of file diff --git a/spec/helpers/diff_helper_spec.rb b/spec/helpers/diff_helper_spec.rb index 95719b4b49f..dd4c1d645e2 100644 --- a/spec/helpers/diff_helper_spec.rb +++ b/spec/helpers/diff_helper_spec.rb @@ -5,7 +5,8 @@ describe DiffHelper do let(:project) { create(:project) } let(:commit) { project.commit(sample_commit.id) } - let(:diff) { commit.diffs.first } + let(:diffs) { commit.diffs } + let(:diff) { diffs.first } let(:diff_file) { Gitlab::Diff::File.new(diff) } describe 'diff_hard_limit_enabled?' do @@ -30,6 +31,57 @@ describe DiffHelper do end end + describe 'allowed_diff_lines' do + it 'should return hard limit for number of lines in a diff if force diff is true' do + allow(controller).to receive(:params) { { force_show_diff: true } } + expect(allowed_diff_lines).to eq(50000) + end + + it 'should return safe limit for numbers of lines a diff if force diff is false' do + expect(allowed_diff_lines).to eq(5000) + end + end + + describe 'safe_diff_files' do + it 'should return all files from a commit that is smaller than safe limits' do + expect(safe_diff_files(diffs).length).to eq(2) + end + + it 'should return only the first file if the diff line count in the 2nd file takes the total beyond safe limits' do + diffs[1].diff.stub(lines: [""] * 4999) #simulate 4999 lines + expect(safe_diff_files(diffs).length).to eq(1) + end + + it 'should return all files from a commit that is beyond safe limit for numbers of lines if force diff is true' do + allow(controller).to receive(:params) { { force_show_diff: true } } + diffs[1].diff.stub(lines: [""] * 4999) #simulate 4999 lines + expect(safe_diff_files(diffs).length).to eq(2) + end + + it 'should return only the first file if the diff line count in the 2nd file takes the total beyond hard limits' do + allow(controller).to receive(:params) { { force_show_diff: true } } + diffs[1].diff.stub(lines: [""] * 49999) #simulate 49999 lines + expect(safe_diff_files(diffs).length).to eq(1) + end + + it 'should return only a safe number of file diffs if a commit touches more files than the safe limits' do + large_diffs = diffs * 100 #simulate 200 diffs + expect(safe_diff_files(large_diffs).length).to eq(100) + end + + it 'should return all file diffs if a commit touches more files than the safe limits but force diff is true' do + allow(controller).to receive(:params) { { force_show_diff: true } } + large_diffs = diffs * 100 #simulate 200 diffs + expect(safe_diff_files(large_diffs).length).to eq(200) + end + + it 'should return a limited file diffs if a commit touches more files than the hard limits and force diff is true' do + allow(controller).to receive(:params) { { force_show_diff: true } } + very_large_diffs = diffs * 1000 #simulate 2000 diffs + expect(safe_diff_files(very_large_diffs).length).to eq(1000) + end + end + describe 'parallel_diff' do it 'should return an array of arrays containing the parsed diff' do expect(parallel_diff(diff_file, 0)). diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb index af37e8319a4..e7558f28768 100644 --- a/spec/services/git_push_service_spec.rb +++ b/spec/services/git_push_service_spec.rb @@ -234,5 +234,18 @@ describe GitPushService do expect(Issue.find(issue.id)).to be_opened end end -end + describe "empty project" do + let(:project) { create(:project_empty_repo) } + let(:new_ref) { 'refs/heads/feature'} + + before do + allow(project).to receive(:default_branch).and_return('feature') + expect(project).to receive(:change_head) { 'feature'} + end + + it 'push to first branch updates HEAD' do + service.execute(project, user, @blankrev, @newrev, new_ref) + end + end +end |