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
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
......@@ -49,6 +49,6 @@ class Environment < ActiveRecord::Base
end
def ref_path
"refs/environments/#{Shellwords.shellescape(name)}/"
"refs/environments/#{Shellwords.shellescape(name)}"
end
end
......@@ -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
......
......@@ -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:
```
......
......@@ -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)
......
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