summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZ.J. van de Weg <zegerjan@gitlab.com>2016-10-03 15:39:12 +0200
committerZ.J. van de Weg <zegerjan@gitlab.com>2016-10-04 09:54:31 +0200
commit901c994b7a4481437f8fe91583d2ed3f19e4775e (patch)
treefaf1598797c6bf1eb27d596afbb76350de25ecf4
parent8fd91794382899e9e352af493a699198d7867f96 (diff)
downloadgitlab-ce-901c994b7a4481437f8fe91583d2ed3f19e4775e.tar.gz
deployment refs in own folder, new method for creating refszj-save-environment-deployment-refs
-rw-r--r--app/models/deployment.rb4
-rw-r--r--app/models/environment.rb2
-rw-r--r--app/models/repository.rb4
-rw-r--r--doc/ci/environments.md2
-rw-r--r--spec/models/repository_spec.rb10
5 files changed, 18 insertions, 4 deletions
diff --git a/app/models/deployment.rb b/app/models/deployment.rb
index bfcfd4f2e11..82b27b78229 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 843f85883a1..f0f3ee23223 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 51557228ab9..eb574555df6 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 081766d5ee9..e070302fb82 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 db29f4d353b..98c64c079b9 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)