summaryrefslogtreecommitdiff
path: root/app/models/commit.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-11-05 15:13:34 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-11-05 15:13:34 +0200
commitf17c4950fa5a951102d5592dc962f20e302b44aa (patch)
tree9c6f7078d1db168d8154739d52fc062d5987c3c4 /app/models/commit.rb
parent056df41ed16f6eddf3271caad93a118f97e8b58c (diff)
downloadgitlab-ci-f17c4950fa5a951102d5592dc962f20e302b44aa.tar.gz
Refactor commits/builds logic
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r--app/models/commit.rb23
1 files changed, 4 insertions, 19 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 4abe0da..6817101 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -76,24 +76,6 @@ class Commit < ActiveRecord::Base
nil
end
- # Build a clone-able repo url
- # using http and basic auth
- def repo_url
- auth = "gitlab-ci-token:#{project.token}@"
- url = project.gitlab_url + ".git"
- url.sub(/^https?:\/\//) do |prefix|
- prefix + auth
- end
- end
-
- def allow_git_fetch
- project.allow_git_fetch
- end
-
- def project_name
- project.name
- end
-
def project_recipients
recipients = project.email_recipients.split(' ')
recipients << git_author_email if project.email_add_committer?
@@ -153,17 +135,20 @@ class Commit < ActiveRecord::Base
status == 'failed'
end
+ # TODO: implement
def canceled?
end
def duration
+ @duration ||= builds.select(&:finished_at).sum(&:duration)
end
def finished_at
+ @finished_at ||= builds.order('finished_at ASC').first.try(:finished_at)
end
def coverage
- if builds.size == 1
+ if project.coverage_enabled? && builds.size == 1
builds.first.coverage
end
end