diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index a13458aabf0f5528afa7c90d3d195bae9f2314a1..f6120e68db5331dddb3c81d06d22fcb077c2b5cf 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -531,7 +531,7 @@ table a code { /** FLASH message **/ #flash_container { - height:45px; + height:50px; position:fixed; z-index:10001; top:0px; @@ -540,7 +540,7 @@ table a code { overflow:hidden; background:white; cursor:pointer; - border-bottom:1px solid #777; + border-bottom:1px solid #ccc; h4 { color:#444; @@ -901,3 +901,23 @@ p.time { margin:2px; } } + +.mr_source_commit , +.mr_target_commit { + .commit { + list-style:none; + margin-top:10px; + &:hover { + background:none; + } + } +} + +.prettyprint { + background-color: #fefbf3; + padding: 9px; + border: 1px solid rgba(0,0,0,.2); + -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.1); + -moz-box-shadow: 0 1px 2px rgba(0,0,0,.1); + box-shadow: 0 1px 2px rgba(0,0,0,.1); +} diff --git a/app/controllers/merge_requests_controller.rb b/app/controllers/merge_requests_controller.rb index bb13fecc946114a6bfc524b9464a69e9434c9a82..d1d19efc98cb46a721f5b839f3f908e10a53d6a5 100644 --- a/app/controllers/merge_requests_controller.rb +++ b/app/controllers/merge_requests_controller.rb @@ -106,6 +106,14 @@ class MergeRequestsController < ApplicationController end end + def branch_from + @commit = project.commit(params[:ref]) + end + + def branch_to + @commit = project.commit(params[:ref]) + end + protected def merge_request diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 978727243f679bb1e6bea4a71d48b17046082eb4..cd44a25fa821a2a81c755df32f1d06e792374200 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -12,6 +12,7 @@ class MergeRequest < ActiveRecord::Base validates_presence_of :author_id validates_presence_of :source_branch validates_presence_of :target_branch + validate :validate_branches delegate :name, :email, @@ -31,6 +32,13 @@ class MergeRequest < ActiveRecord::Base scope :closed, where(:closed => true) scope :assigned, lambda { |u| where(:assignee_id => u.id)} + + def validate_branches + if target_branch == source_branch + errors.add :base, "You can not use same branch for source and target branches" + end + end + def new? today? && created_at == updated_at end diff --git a/app/views/merge_requests/_form.html.haml b/app/views/merge_requests/_form.html.haml index c0440e07275967e4663082f7dc6fd97bb3135d2f..8ec3f63ca83d2a0bbb5a673bda9cf4ee2cee4f7e 100644 --- a/app/views/merge_requests/_form.html.haml +++ b/app/views/merge_requests/_form.html.haml @@ -10,10 +10,14 @@ .input= f.text_area :title, :class => "xxlarge", :maxlength => 255, :rows => 5 .clearfix = f.label :source_branch, "From" - .input= f.select(:source_branch, @project.heads.map(&:name), { :include_blank => "Select branch" }, :style => "width:250px") + .input + = f.select(:source_branch, @project.heads.map(&:name), { :include_blank => "Select branch" }, :style => "width:250px") + .mr_source_commit .clearfix = f.label :target_branch, "To" - .input= f.select(:target_branch, @project.heads.map(&:name), { :include_blank => "Select branch" }, :style => "width:250px") + .input + = f.select(:target_branch, @project.heads.map(&:name), { :include_blank => "Select branch" }, :style => "width:250px") + .mr_target_commit .clearfix = f.label :assignee_id, "Assign to" .input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Select user" }, :style => "width:250px") @@ -34,5 +38,15 @@ $('select#merge_request_assignee_id').chosen(); $('select#merge_request_source_branch').chosen(); $('select#merge_request_target_branch').chosen(); + + + + $("#merge_request_source_branch").live("change", function() { + $.get("#{branch_from_project_merge_requests_path(@project)}", {ref: $(this).val() }); + }); + + $("#merge_request_target_branch").live("change", function() { + $.get("#{branch_to_project_merge_requests_path(@project)}", {ref: $(this).val() }); + }); }); diff --git a/app/views/merge_requests/branch_from.js.haml b/app/views/merge_requests/branch_from.js.haml new file mode 100644 index 0000000000000000000000000000000000000000..3e278015b49a74b1f05e25bbed0ef2bcbe42027d --- /dev/null +++ b/app/views/merge_requests/branch_from.js.haml @@ -0,0 +1,2 @@ +:plain + $(".mr_source_commit").html("#{escape_javascript(render 'commits/commit', :commit => @commit)}"); diff --git a/app/views/merge_requests/branch_to.js.haml b/app/views/merge_requests/branch_to.js.haml new file mode 100644 index 0000000000000000000000000000000000000000..1ab1f6c43a91ffcfee6d221b3672182e5e305ea8 --- /dev/null +++ b/app/views/merge_requests/branch_to.js.haml @@ -0,0 +1,3 @@ +:plain + $(".mr_target_commit").html("#{escape_javascript(render 'commits/commit', :commit => @commit)}"); + diff --git a/config/routes.rb b/config/routes.rb index 77c20380472566b00b9849a6d090e4be2146937b..4cc3a4ff77bdf486a8305871f911c4cfb7e2c2bd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -101,6 +101,11 @@ Gitlab::Application.routes.draw do member do get :diffs end + + collection do + get :branch_from + get :branch_to + end end resources :snippets diff --git a/db/fixtures/test/001_repo.rb b/db/fixtures/test/001_repo.rb index fa50f84136266e09d47bb52986b4be9abfa0e7c5..ebf005a14679e873e3c11f6eaa55e32a40581882 100644 --- a/db/fixtures/test/001_repo.rb +++ b/db/fixtures/test/001_repo.rb @@ -10,6 +10,6 @@ Dir.mkdir(repo_dir) unless File.exists?(repo_dir) Dir.chdir(repo_dir) `tar -xf seed_project.tar.gz` 3.times do |i| -`cp -r legit/ legit_#{i}/` -puts "Unpacked seed repo - tmp/tests/legit_#{i}" +`cp -r gitlabhq/ gitlabhq_#{i}/` +puts "Unpacked seed repo - tmp/tests/gitlabhq_#{i}" end diff --git a/spec/factories.rb b/spec/factories.rb index 2ca8d7649adf43af64bd9611061896ae884afa70..ac1ea051766fb81288fe95b46ade4d3ae93e0d79 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -2,14 +2,14 @@ require File.join(Rails.root, 'spec', 'factory') Factory.add(:project, Project) do |obj| obj.name = Faker::Internet.user_name - obj.path = 'legit' + obj.path = 'gitlabhq' obj.owner = Factory(:user) obj.code = 'LGT' end Factory.add(:public_project, Project) do |obj| obj.name = Faker::Internet.user_name - obj.path = 'legit' + obj.path = 'gitlabhq' obj.private_flag = false obj.owner = Factory(:user) obj.code = 'LGT' @@ -41,7 +41,7 @@ Factory.add(:merge_request, MergeRequest) do |obj| obj.author = Factory :user obj.assignee = Factory :user obj.source_branch = "master" - obj.target_branch = "master" + obj.target_branch = "stable" obj.closed = false end diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index 70eba5cc1945718d922a54ffda0deff5e7e4844d..f36f12dd6ec4bafcf9b222b13fe09a03dd7db005 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -54,7 +54,7 @@ describe Note do describe :authorization do before do @p1 = project - @p2 = Factory :project, :code => "alien", :path => "legit_1" + @p2 = Factory :project, :code => "alien", :path => "gitlabhq_1" @u1 = Factory :user @u2 = Factory :user @u3 = Factory :user diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index bb76bbc4f34aee1c3b4f3a4e18d3930e1a040e4f..cb28a7eca380ed79a00c69468e950f807acd0469 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -86,23 +86,22 @@ describe Project do let(:project) { Factory :project } it { project.fresh_commits(3).count.should == 3 } - it { project.fresh_commits.first.id.should == "2fb376f61875b58bceee0492e270e9c805294b1a" } - it { project.fresh_commits.last.id.should == "0dac878dbfe0b9c6104a87d65fe999149a8d862c" } + it { project.fresh_commits.first.id.should == "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a" } + it { project.fresh_commits.last.id.should == "f403da73f5e62794a0447aca879360494b08f678" } end describe "commits_between" do let(:project) { Factory :project } subject do - commits = project.commits_between("a6d1d4aca0c85816ddfd27d93773f43a31395033", - "2fb376f61875b58bceee0492e270e9c805294b1a") + commits = project.commits_between("3a4b4fb4cde7809f033822a171b9feae19d41fff", + "8470d70da67355c9c009e4401746b1d5410af2e3") commits.map { |c| c.id } end - it { should have(2).elements } - it { should include("2fb376f61875b58bceee0492e270e9c805294b1a") } - it { should include("4571e226fbcd7be1af16e9fa1e13b7ac003bebdf") } - it { should_not include("a6d1d4aca0c85816ddfd27d93773f43a31395033") } + it { should have(3).elements } + it { should include("f0f14c8eaba69ebddd766498a9d0b0e79becd633") } + it { should_not include("bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a") } end describe "Git methods" do diff --git a/spec/requests/admin/admin_projects_spec.rb b/spec/requests/admin/admin_projects_spec.rb index ceaf7245a1057b74b7a1bdf0b75be0105208ff8f..9a33c6936a7041f9d518dad51b69e8819c42f04e 100644 --- a/spec/requests/admin/admin_projects_spec.rb +++ b/spec/requests/admin/admin_projects_spec.rb @@ -87,7 +87,7 @@ describe "Admin::Projects" do visit new_admin_project_path fill_in 'Name', :with => 'NewProject' fill_in 'Code', :with => 'NPR' - fill_in 'Path', :with => 'legit_1' + fill_in 'Path', :with => 'gitlabhq_1' expect { click_button "Save" }.to change { Project.count }.by(1) @project = Project.last end diff --git a/spec/requests/merge_requests_spec.rb b/spec/requests/merge_requests_spec.rb index f7b7e919ca834772ff4dfe3385a1f29093cd7f24..f4e25cab856640cb2221c7872f1112f44d9597dd 100644 --- a/spec/requests/merge_requests_spec.rb +++ b/spec/requests/merge_requests_spec.rb @@ -52,7 +52,7 @@ describe "MergeRequests" do visit new_project_merge_request_path(project) fill_in "merge_request_title", :with => "Merge Request Title" select "master", :from => "merge_request_source_branch" - select "master", :from => "merge_request_target_branch" + select "stable", :from => "merge_request_target_branch" select @user.name, :from => "merge_request_assignee_id" click_button "Save" end diff --git a/spec/requests/projects_spec.rb b/spec/requests/projects_spec.rb index e6b6f19cbcdd562d5112616299b3e9c0c5949523..f3be80752835a39a9a31b671f228885526a6790f 100644 --- a/spec/requests/projects_spec.rb +++ b/spec/requests/projects_spec.rb @@ -134,7 +134,7 @@ describe "Projects" do visit edit_project_path(@project) fill_in 'Name', :with => 'Awesome' - fill_in 'Path', :with => 'legit' + fill_in 'Path', :with => 'gitlabhq' fill_in 'Description', :with => 'Awesome project' click_button "Save" @project = @project.reload diff --git a/spec/requests/projects_tree_spec.rb b/spec/requests/projects_tree_spec.rb index fe4f81b39e71673725f444b0a01113b4f8eb526c..acc4f0b9674d6eb4b4d070d67e04dc1cb4139dca 100644 --- a/spec/requests/projects_tree_spec.rb +++ b/spec/requests/projects_tree_spec.rb @@ -57,7 +57,7 @@ describe "Projects" do @project = Factory :project @project.add_access(@user, :read) - visit tree_project_ref_path(@project, @project.root_ref, :path => ".rvmrc") + visit tree_project_ref_path(@project, @project.root_ref, :path => "Gemfile") end it "should be correct path" do @@ -65,7 +65,7 @@ describe "Projects" do end it "should contain file view" do - page.should have_content("rvm use 1.9.2@legit") + page.should have_content("rubygems.org") end end end diff --git a/spec/requests/repositories_spec.rb b/spec/requests/repositories_spec.rb index 3fb5371bbbf441420a547a11c64340fefccf0735..1bf4c8d24b754b08863fe232449804f6ac9f94f2 100644 --- a/spec/requests/repositories_spec.rb +++ b/spec/requests/repositories_spec.rb @@ -42,7 +42,7 @@ describe "Repository" do it "should have link to repo activities" do page.should have_content("Tags") - page.should have_content("No tags") + page.should have_content("v1.2.1") end end end diff --git a/spec/seed_project.tar.gz b/spec/seed_project.tar.gz index 6474c324f074c7ca76cbaf855091bd2882329927..3ffafed18d0f47aa0d89e24b5a8a7321bc7210a2 100644 Binary files a/spec/seed_project.tar.gz and b/spec/seed_project.tar.gz differ diff --git a/spec/support/valid_commit.rb b/spec/support/valid_commit.rb index a4d3496e241c0d5b6ad94212c5936157b29eec52..8094b679e991e088947cf6102d682ce987da1590 100644 --- a/spec/support/valid_commit.rb +++ b/spec/support/valid_commit.rb @@ -1,25 +1,15 @@ module ValidCommit - ID = "eaffbe556ec3a8dc84ef15892a9f12d84dde7e1d" - MESSAGE = "style" + ID = "8470d70da67355c9c009e4401746b1d5410af2e3" + MESSAGE = "notes controller refactored" AUTHOR_FULL_NAME = "Dmitriy Zaporozhets" - FILES = [".gitignore", ".rspec", ".rvmrc", "Gemfile", "Gemfile.lock", "LICENSE", "README.rdoc", "Rakefile", "app", "config.ru", "config", "db", "doc", "lib", "log", "public", "script", "spec", "vendor"] - FILES_COUNT = 19 + FILES = [".foreman", ".gitignore", ".rails_footnotes", ".rspec", ".travis.yml", "CHANGELOG", "Gemfile", "Gemfile.lock", "LICENSE", "Procfile", "Procfile.production", "README.md", "Rakefile", "VERSION", "app", "config.ru", "config", "db", "doc", "lib", "log", "public", "resque.sh", "script", "spec", "vendor"] + FILES_COUNT = 26 C_FILE_PATH = "app/models" - C_FILES = [".gitkeep", "project.rb", "user.rb"] + C_FILES = [".gitkeep", "ability.rb", "commit.rb", "issue.rb", "key.rb", "mailer_observer.rb", "merge_request.rb", "note.rb", "project.rb", "protected_branch.rb", "repository.rb", "snippet.rb", "tree.rb", "user.rb", "users_project.rb", "web_hook.rb", "wiki.rb"] - BLOB_FILE = <<-blob -<div class="span-14 colborder"> - <h2>Tree / <%= link_to "Commits", project_commits_path(@project) %></h2> - <%= render :partial => "tree", :locals => {:repo => @repo, :commit => @commit, :tree => @commit.tree} %> -</div> - -<div class="span-8 right"> - <%= render "side_panel" %> -</div> -blob - - BLOB_FILE_PATH = "app/views/projects/show.html.erb" + BLOB_FILE = %{%h3= @key.title\n%hr\n%pre= @key.key\n.actions\n = link_to 'Remove', @key, :confirm => 'Are you sure?', :method => :delete, :class => \"btn danger delete-key\"\n\n\n} + BLOB_FILE_PATH = "app/views/keys/show.html.haml" end