Merge branch 'master' into fixes/api, code clean up and tests fixed
Conflicts: doc/api/projects.md spec/requests/api/projects_spec.rb
This commit is contained in:
commit
3374027e3a
49 changed files with 820 additions and 163 deletions
|
@ -91,7 +91,7 @@ class MergeRequest < ActiveRecord::Base
|
|||
|
||||
def validate_branches
|
||||
if target_branch == source_branch
|
||||
errors.add :base, "You can not use same branch for source and target branches"
|
||||
errors.add :branch_conflict, "You can not use same branch for source and target branches"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
class Repository
|
||||
include Gitlab::Popen
|
||||
|
||||
# Repository directory name with namespace direcotry
|
||||
# Examples:
|
||||
# gitlab/gitolite
|
||||
|
@ -147,4 +149,21 @@ class Repository
|
|||
|
||||
file_path
|
||||
end
|
||||
|
||||
# Return repo size in megabytes
|
||||
# Cached in redis
|
||||
def size
|
||||
Rails.cache.fetch(cache_key(:size)) do
|
||||
size = popen('du -s', path_to_repo).first.strip.to_i
|
||||
(size.to_f / 1024).round(2)
|
||||
end
|
||||
end
|
||||
|
||||
def expire_cache
|
||||
Rails.cache.delete(cache_key(:size))
|
||||
end
|
||||
|
||||
def cache_key(type)
|
||||
"#{type}:#{path_with_namespace}"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue