diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-08-30 18:03:16 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-08-30 18:03:16 +0000 |
commit | 51087cfa1a6b0bb5a7abf35081ed3b669253eb4f (patch) | |
tree | 3a90808c1671f9ba1686c3a593e84081a3162c4b /app/models/project.rb | |
parent | 90c7a4117a68f5e019fed314076f6fcefbed9ac0 (diff) | |
parent | 41a0b7b22f7cdec7d216f32d561442c9fc3587be (diff) | |
download | gitlab-ce-51087cfa1a6b0bb5a7abf35081ed3b669253eb4f.tar.gz |
Merge branch 'artifacts-from-ref-and-build-name' into 'master'
Add a download buttons for Build Artifacts
## What does this MR do?
This MR adds a download buttons for build artifacts of latest succesful pipeline in:
- dashboard of project,
- branches and tags views,
- and tree viewer
Implement #4255
## What are the relevant issue numbers?
Closes #4255, Closes #14419
## Screenshots
### Project main

### Branches

### Tags

### Source Tree

## Does this MR meet the acceptance criteria?
- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [x] Download buttons
- [x] Models
- [x] Routes
- [x] Projects::ArtifactsController
- [x] API
- Tests
- Rails
- [x] Project#builds_for
- [x] branch name with slashes
- [x] only success builds
- [x] only latest builds
- [x] feature tests for download buttons
- API
- [x] branch name with slashes
- [x] only success builds
- [x] only latest builds
- [x] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)
See merge request !5142
Diffstat (limited to 'app/models/project.rb')
-rw-r--r-- | app/models/project.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 0fa41ebbec3..c34064f96ce 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -436,7 +436,7 @@ class Project < ActiveRecord::Base # ref can't be HEAD, can only be branch/tag name or SHA def latest_successful_builds_for(ref = default_branch) - latest_pipeline = pipelines.latest_successful_for(ref).first + latest_pipeline = pipelines.latest_successful_for(ref) if latest_pipeline latest_pipeline.builds.latest.with_artifacts @@ -1100,12 +1100,17 @@ class Project < ActiveRecord::Base !namespace.share_with_group_lock end - def pipeline(sha, ref) + def pipeline_for(ref, sha = nil) + sha ||= commit(ref).try(:sha) + + return unless sha + pipelines.order(id: :desc).find_by(sha: sha, ref: ref) end - def ensure_pipeline(sha, ref, current_user = nil) - pipeline(sha, ref) || pipelines.create(sha: sha, ref: ref, user: current_user) + def ensure_pipeline(ref, sha, current_user = nil) + pipeline_for(ref, sha) || + pipelines.create(sha: sha, ref: ref, user: current_user) end def enable_ci |