Commit 901c994b authored by Z.J. van de Weg's avatar Z.J. van de Weg

deployment refs in own folder, new method for creating refs

parent 8fd91794
...@@ -30,7 +30,7 @@ class Deployment < ActiveRecord::Base ...@@ -30,7 +30,7 @@ class Deployment < ActiveRecord::Base
end end
def create_ref def create_ref
project.repository.fetch_ref(project.repository.path_to_repo, ref, ref_path) project.repository.create_ref(ref, ref_path)
end end
def manual_actions def manual_actions
...@@ -80,6 +80,6 @@ class Deployment < ActiveRecord::Base ...@@ -80,6 +80,6 @@ class Deployment < ActiveRecord::Base
private private
def ref_path def ref_path
"#{environment.ref_path}#{id}" File.join(environment.ref_path, 'deployments', id.to_s)
end end
end end
...@@ -49,6 +49,6 @@ class Environment < ActiveRecord::Base ...@@ -49,6 +49,6 @@ class Environment < ActiveRecord::Base
end end
def ref_path def ref_path
"refs/environments/#{Shellwords.shellescape(name)}/" "refs/environments/#{Shellwords.shellescape(name)}"
end end
end end
...@@ -997,6 +997,10 @@ class Repository ...@@ -997,6 +997,10 @@ class Repository
Gitlab::Popen.popen(args, path_to_repo) Gitlab::Popen.popen(args, path_to_repo)
end end
def create_ref(ref, ref_path)
fetch_ref(path_to_repo, ref, ref_path)
end
def update_branch_with_hooks(current_user, branch) def update_branch_with_hooks(current_user, branch)
update_autocrlf_option update_autocrlf_option
......
...@@ -20,7 +20,7 @@ Since 8.13, a reference in the git repository is saved for each deployment. So ...@@ -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` knowing what the state is of your current environments is only a `git fetch`
away. 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: fetch line:
``` ```
......
...@@ -320,6 +320,16 @@ describe Repository, models: true do ...@@ -320,6 +320,16 @@ describe Repository, models: true do
end end
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 describe "#changelog" do
before do before do
repository.send(:cache).expire(:changelog) repository.send(:cache).expire(:changelog)
......
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