diff --git a/app/models/deployment.rb b/app/models/deployment.rb index bfcfd4f2e11f166bac5b4350f43651d0a677efae..82b27b78229a94c7796fc894e814cc9ad48b5fbe 100644 --- a/app/models/deployment.rb +++ b/app/models/deployment.rb @@ -30,7 +30,7 @@ class Deployment < ActiveRecord::Base end def create_ref - project.repository.fetch_ref(project.repository.path_to_repo, ref, ref_path) + project.repository.create_ref(ref, ref_path) end def manual_actions @@ -80,6 +80,6 @@ class Deployment < ActiveRecord::Base private def ref_path - "#{environment.ref_path}#{id}" + File.join(environment.ref_path, 'deployments', id.to_s) end end diff --git a/app/models/environment.rb b/app/models/environment.rb index 843f85883a1391d7ed048f682b97955d4953a339..f0f3ee23223e2bdb33a3ee2246a4e6d97fdf07f9 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -49,6 +49,6 @@ class Environment < ActiveRecord::Base end def ref_path - "refs/environments/#{Shellwords.shellescape(name)}/" + "refs/environments/#{Shellwords.shellescape(name)}" end end diff --git a/app/models/repository.rb b/app/models/repository.rb index 51557228ab9ffb83f53cc3b9d2cba533befd8996..eb574555df66557880f948d263c16a81bb178a1f 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -997,6 +997,10 @@ class Repository Gitlab::Popen.popen(args, path_to_repo) end + def create_ref(ref, ref_path) + fetch_ref(path_to_repo, ref, ref_path) + end + def update_branch_with_hooks(current_user, branch) update_autocrlf_option diff --git a/doc/ci/environments.md b/doc/ci/environments.md index 081766d5ee91a7b84ca7fba4a81c206e1993e558..e070302fb826e3051456b7952d310cce8f77232f 100644 --- a/doc/ci/environments.md +++ b/doc/ci/environments.md @@ -20,7 +20,7 @@ Since 8.13, a reference in the git repository is saved for each deployment. So knowing what the state is of your current environments is only a `git fetch` away. -In your git config, append the `[remote "<your-remote>"] block with an extra +In your git config, append the `[remote "<your-remote>"]` block with an extra fetch line: ``` diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index db29f4d353bd14d250928573af74bd7beee5383d..98c64c079b9dd163437b7cd7f64b037547b067aa 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -320,6 +320,16 @@ describe Repository, models: true do end end + describe '#create_ref' do + it 'redirects the call to fetch_ref' do + ref, ref_path = '1', '2' + + expect(repository).to receive(:fetch_ref).with(repository.path_to_repo, ref, ref_path) + + repository.create_ref(ref, ref_path) + end + end + describe "#changelog" do before do repository.send(:cache).expire(:changelog)