diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-11-06 18:24:19 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-11-06 18:24:19 +0000 |
commit | 253680bbffe2423a11d4fa8626c2b35c289ea8cc (patch) | |
tree | 5fd8dee3056ef3d26eb84fa5093fc568e13c2786 /app/models | |
parent | d618a5fec361b85fafffd5cf4a53d044e82bdb5a (diff) | |
parent | 7ab3bf9668195cb2a885db6a78078f0d6e24ea54 (diff) | |
download | gitlab-ce-253680bbffe2423a11d4fa8626c2b35c289ea8cc.tar.gz |
Merge branch 'improve/default_branch' of /home/git/repositories/gitlab/gitlabhq
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/project.rb | 10 | ||||
-rw-r--r-- | app/models/repository.rb | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 52682ac0a9e..65d42b6b870 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -28,7 +28,7 @@ class Project < ActiveRecord::Base include Gitlab::ShellAdapter extend Enumerize - attr_accessible :name, :path, :description, :default_branch, :issues_tracker, :label_list, + attr_accessible :name, :path, :description, :issues_tracker, :label_list, :issues_enabled, :wall_enabled, :merge_requests_enabled, :snippets_enabled, :issues_tracker_id, :wiki_enabled, :public, :import_url, :last_activity_at, as: [:default, :admin] @@ -36,6 +36,8 @@ class Project < ActiveRecord::Base acts_as_taggable_on :labels, :issues_default_labels + attr_accessor :new_default_branch + # Relations belongs_to :creator, foreign_key: "creator_id", class_name: "User" belongs_to :group, foreign_key: "namespace_id", conditions: "type = 'Group'" @@ -143,7 +145,7 @@ class Project < ActiveRecord::Base end def repository - @repository ||= Repository.new(path_with_namespace, default_branch) + @repository ||= Repository.new(path_with_namespace) end def saved? @@ -451,4 +453,8 @@ class Project < ActiveRecord::Base def project_member(user) users_projects.where(user_id: user).first end + + def default_branch + @default_branch ||= repository.root_ref if repository.exists? + end end diff --git a/app/models/repository.rb b/app/models/repository.rb index 97b4330092a..80918d6de4b 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -3,7 +3,7 @@ class Repository attr_accessor :raw_repository, :path_with_namespace - def initialize(path_with_namespace, default_branch) + def initialize(path_with_namespace, default_branch = nil) @path_with_namespace = path_with_namespace @raw_repository = Gitlab::Git::Repository.new(path_to_repo) if path_with_namespace rescue Gitlab::Git::Repository::NoRepository |