summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-05-04 18:11:20 +0300
committerValery Sizov <vsv2711@gmail.com>2015-05-04 18:11:20 +0300
commitce534e9395b9c6eaaef7400547a5adc613f046a7 (patch)
treec869863d978a26d4864436d91d129b635c18d564 /app/models
parent5b7589664297fd066324acfb9b6eafe2ad1d432c (diff)
downloadgitlab-ci-ce534e9395b9c6eaaef7400547a5adc613f046a7.tar.gz
Refactoring. Clean up advanced settings. Migrate from gotlab_url to path
Diffstat (limited to 'app/models')
-rw-r--r--app/models/commit.rb6
-rw-r--r--app/models/project.rb14
-rw-r--r--app/models/project_services/slack_message.rb12
3 files changed, 10 insertions, 22 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index bc33350..6c876bd 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -51,11 +51,7 @@ class Commit < ActiveRecord::Base
end
def compare?
- gitlab? && !new_branch?
- end
-
- def gitlab?
- project.gitlab?
+ !new_branch?
end
def git_author_name
diff --git a/app/models/project.rb b/app/models/project.rb
index c48b079..f648833 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -9,7 +9,7 @@
# updated_at :datetime
# token :string(255)
# default_ref :string(255)
-# gitlab_url :string(255)
+# path :string(255)
# always_build :boolean default(FALSE), not null
# polling_interval :integer
# public :boolean default(FALSE), not null
@@ -47,7 +47,7 @@ class Project < ActiveRecord::Base
# Validations
#
validates_presence_of :name, :timeout, :token, :default_ref,
- :gitlab_url, :ssh_url_to_repo, :gitlab_id
+ :path, :ssh_url_to_repo, :gitlab_id
validates_uniqueness_of :name
@@ -79,7 +79,7 @@ ls -la
params = {
name: project.name_with_namespace,
gitlab_id: project.id,
- gitlab_url: project.web_url,
+ path: project.path_with_namespace,
default_ref: project.default_branch || 'master',
ssh_url_to_repo: project.ssh_url_to_repo,
email_add_pusher: GitlabCi.config.gitlab_ci.add_pusher,
@@ -130,10 +130,6 @@ ls -la
self.token = SecureRandom.hex(15) if self.token.blank?
end
- def gitlab?
- gitlab_url.present?
- end
-
def tracked_refs
@tracked_refs ||= default_ref.split(",").map{|ref| ref.strip}
end
@@ -236,6 +232,10 @@ ls -la
end
end
+ def gitlab_url
+ File.join(GitlabCi.config.gitlab_server.url, path)
+ end
+
def setup_finished?
commits.any?
end
diff --git a/app/models/project_services/slack_message.rb b/app/models/project_services/slack_message.rb
index 8d8bfcf..c95499e 100644
--- a/app/models/project_services/slack_message.rb
+++ b/app/models/project_services/slack_message.rb
@@ -69,19 +69,11 @@ class SlackMessage
end
def commit_sha_link
- if commit.project.gitlab?
- "#{project.gitlab_url}/commit/#{commit.sha}"
- else
- commit.ref
- end
+ "#{project.gitlab_url}/commit/#{commit.sha}"
end
def commit_ref_link
- if commit.project.gitlab?
- "#{project.gitlab_url}/commits/#{commit.ref}"
- else
- commit.ref
- end
+ "#{project.gitlab_url}/commits/#{commit.ref}"
end
def attachment_color