Skip to content

Commit

Permalink
Merge 7968c7f into 3b33b5e
Browse files Browse the repository at this point in the history
  • Loading branch information
smcv committed Feb 19, 2014
2 parents 3b33b5e + 7968c7f commit 7051972
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 7 deletions.
18 changes: 18 additions & 0 deletions docs/api/api/configuration.rng
Expand Up @@ -124,6 +124,24 @@
</choice>
</element>
</optional>
<optional>
<element name="cleanup_empty_projects">
<!-- If the last package in a project is cleaned up by sourceupdate=cleanup, delete the whole project? -->
<choice>
<value>on</value>
<value>off</value>
</choice>
</element>
</optional>
<optional>
<element name="disable_publish_for_branches">
<!-- When a user creates a new project as a side-effect of branching a package, disable publishing that project? The default is "on" to save disk space and bandwidth. -->
<choice>
<value>on</value>
<value>off</value>
</choice>
</element>
</optional>

<!-- webui only stuff -->
<optional>
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/bs_request_action.rb
Expand Up @@ -415,7 +415,7 @@ def source_cleanup

def source_cleanup_delete_path
source_project = Project.find_by_name!(self.source_project)
if source_project.packages.count == 1 or !self.source_package
if (source_project.packages.count == 1 and ::Configuration.first.cleanup_empty_projects) or !self.source_package

# remove source project, if this is the only package and not a user's home project
splits = self.source_project.split(':')
Expand Down
4 changes: 3 additions & 1 deletion src/api/app/models/configuration.rb
Expand Up @@ -26,8 +26,10 @@ class Configuration < ActiveRecord::Base
:no_proxy => nil,
:cleanup_after_days => nil,
:theme => CONFIG['theme'],
:cleanup_empty_projects => nil,
:disable_publish_for_branches => nil,
}
ON_OFF_OPTIONS = [ :anonymous, :default_access_disabled, :allow_user_to_create_home_project, :disallow_group_creation, :change_password, :hide_private_options, :gravatar, :download_on_demand, :enforce_project_keys ]
ON_OFF_OPTIONS = [ :anonymous, :default_access_disabled, :allow_user_to_create_home_project, :disallow_group_creation, :change_password, :hide_private_options, :gravatar, :download_on_demand, :enforce_project_keys, :cleanup_empty_projects, :disable_publish_for_branches ]

class << self
def map_value(key, value)
Expand Down
26 changes: 21 additions & 5 deletions src/api/app/models/project.rb
Expand Up @@ -1070,13 +1070,29 @@ def branch_to_repositories_from(project, pkg_to_enable, extend_names=nil)
end
pkg_to_enable.enable_for_repository(repoName) if pkg_to_enable
end
# take over flags, but explicit disable publishing by default and enable building. Ommiting also lock or we can not create packages

self.branch_copy_flags(project)
end

def branch_copy_flags(project)
# Copy the flags from the other project, adjusting them appropriately
# for this one being a branch of it:
#
# - enable building
# - disable 'publish' to save space and bandwidth
# (can be turned off for small installations)
# - omit 'lock' or we cannot create packages
disable_publish_for_branches = ::Configuration.first.disable_publish_for_branches
project.flags.each do |f|
unless %w(build publish lock).include?(f.flag)
self.flags.create(status: f.status, flag: f.flag, architecture: f.architecture, repo: f.repo)
end
next if %w(build lock).include?(f.flag)
next if f.flag == 'publish' and disable_publish_for_branches

self.flags.create(status: f.status, flag: f.flag, architecture: f.architecture, repo: f.repo)
end

if disable_publish_for_branches
self.flags.create(:status => 'disable', :flag => 'publish') unless self.flags.find_by_flag_and_status( 'publish', 'disable' )
end
self.flags.create(:status => 'disable', :flag => 'publish') unless self.flags.find_by_flag_and_status( 'publish', 'disable' )
end

def open_requests_with_project_as_source_or_target
Expand Down
9 changes: 9 additions & 0 deletions src/api/db/migrate/20140218174400_cleanup_empty_projects.rb
@@ -0,0 +1,9 @@
class CleanupEmptyProjects < ActiveRecord::Migration
def self.up
add_column :configurations, :cleanup_empty_projects, :boolean, :default => true
end

def self.down
remove_column :configurations, :cleanup_empty_projects
end
end
@@ -0,0 +1,9 @@
class DisablePublishForBranches < ActiveRecord::Migration
def self.up
add_column :configurations, :disable_publish_for_branches, :boolean, :default => true
end

def self.down
remove_column :configurations, :disable_publish_for_branches
end
end
6 changes: 6 additions & 0 deletions src/api/db/structure.sql
Expand Up @@ -344,6 +344,8 @@ CREATE TABLE `configurations` (
`theme` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`obs_url` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`cleanup_after_days` int(11) DEFAULT NULL,
`cleanup_empty_projects` tinyint(1) DEFAULT '1',
`disable_publish_for_branches` tinyint(1) DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

Expand Down Expand Up @@ -1442,6 +1444,10 @@ INSERT INTO schema_migrations (version) VALUES ('20140124071042');

INSERT INTO schema_migrations (version) VALUES ('20140210114542');

INSERT INTO schema_migrations (version) VALUES ('20140218174400');

INSERT INTO schema_migrations (version) VALUES ('20140219185200');

INSERT INTO schema_migrations (version) VALUES ('21');

INSERT INTO schema_migrations (version) VALUES ('22');
Expand Down
2 changes: 2 additions & 0 deletions src/backend/BSXML.pm
Expand Up @@ -1471,6 +1471,8 @@ our $configuration = [
'http_proxy',
'no_proxy',
'theme',
'cleanup_empty_projects',
'disable_publish_for_branches',
[ 'schedulers' =>
[ 'arch' ],
],
Expand Down

0 comments on commit 7051972

Please sign in to comment.