summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG1
-rw-r--r--app/models/deployment.rb10
-rw-r--r--app/models/environment.rb4
-rw-r--r--doc/ci/environments.md13
4 files changed, 26 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 806196d811d..e7c059c14d6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,6 +8,7 @@ v 8.13.0 (unreleased)
- Replaced the check sign to arrow in the show build view. !6501
- Add a /wip slash command to toggle the Work In Progress status of a merge request. !6259 (tbalthazar)
- Speed-up group milestones show page
+ - Keep refs for each deployment
- Log LDAP lookup errors and don't swallow unrelated exceptions. !6103 (Markus Koller)
- Add more tests for calendar contribution (ClemMakesApps)
- Avoid database queries on Banzai::ReferenceParser::BaseParser for nodes without references
diff --git a/app/models/deployment.rb b/app/models/deployment.rb
index 07d7e19e70d..cde6598fc7b 100644
--- a/app/models/deployment.rb
+++ b/app/models/deployment.rb
@@ -11,7 +11,7 @@ class Deployment < ActiveRecord::Base
delegate :name, to: :environment, prefix: true
- after_save :keep_around_commit
+ after_save :create_ref
def commit
project.commit(sha)
@@ -30,7 +30,7 @@ class Deployment < ActiveRecord::Base
end
def keep_around_commit
- project.repository.keep_around(self.sha)
+ project.repository.fetch_ref(project.repository.path_to_repo, ref, ref_path)
end
def manual_actions
@@ -76,4 +76,10 @@ class Deployment < ActiveRecord::Base
where.not(id: self.id).
take
end
+
+ private
+
+ def ref_path
+ "#{environment.ref_path}#{id}"
+ end
end
diff --git a/app/models/environment.rb b/app/models/environment.rb
index 49e0a20640c..843f85883a1 100644
--- a/app/models/environment.rb
+++ b/app/models/environment.rb
@@ -47,4 +47,8 @@ class Environment < ActiveRecord::Base
def update_merge_request_metrics?
self.name == "production"
end
+
+ def ref_path
+ "refs/environments/#{Shellwords.shellescape(name)}/"
+ end
end
diff --git a/doc/ci/environments.md b/doc/ci/environments.md
index d85b8a34ced..081766d5ee9 100644
--- a/doc/ci/environments.md
+++ b/doc/ci/environments.md
@@ -14,6 +14,19 @@ Defining environments in a project's `.gitlab-ci.yml` lets developers track
Deployments are created when [jobs] deploy versions of code to [environments].
+### Checkout deployments locally
+
+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
+fetch line:
+
+```
+fetch = +refs/environments/*:refs/remotes/origin/environments/*
+```
+
## Defining environments
You can create and delete environments manually in the web interface, but we