Skip to content

Commit

Permalink
Set group write permissions on repository create (#1797)
Browse files Browse the repository at this point in the history
* Set group write permissions on repository create.

* Set the group permissions for cloned repositories as well.

* Return the result of the pulling method.

* Forbid naming a repository 'new'.
  • Loading branch information
eugenk committed Aug 14, 2016
1 parent 554f2eb commit e6c4495
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/repository/validations.rb
Expand Up @@ -74,7 +74,7 @@ def self.non_present_to_nil(route_part)

# It is against our code style conventions to place a constant here,
# but it is necessary to have all the inherent methods defined above of it.
RESERVED_NAMES = toplevel_namespaces
RESERVED_NAMES = toplevel_namespaces + ['new']
end

class NameNotChangedAfterSetValidator < ActiveModel::Validator
Expand Down
5 changes: 5 additions & 0 deletions lib/git_repository.rb
Expand Up @@ -24,9 +24,14 @@ def initialize(path)
else
FileUtils.mkdir_p(Ontohub::Application.config.git_root)
@repo = Rugged::Repository.init_at(path, true)
set_group_permissions
end
end

def set_group_permissions
FileUtils.chmod_R('g+ws', path)
end

def destroy
FileUtils.rmtree(self.path)
end
Expand Down
8 changes: 6 additions & 2 deletions lib/git_repository/cloning.rb
Expand Up @@ -12,7 +12,9 @@ def clone(url)
fetch: '+refs/*:refs/*',
mirror: 'true'

pull
result = pull
set_group_permissions
result
end

def clone_svn(url)
Expand All @@ -30,7 +32,9 @@ def clone_svn(url)
end

set_section %w(svn-remote svn), options
pull_svn
result = pull_svn
set_group_permissions
result
end

def pull
Expand Down

0 comments on commit e6c4495

Please sign in to comment.