diff --git a/docs/api/api/configuration.rng b/docs/api/api/configuration.rng
index 159517662d64..ce447d7f457d 100644
--- a/docs/api/api/configuration.rng
+++ b/docs/api/api/configuration.rng
@@ -124,6 +124,24 @@
+
+
+
+
+ on
+ off
+
+
+
+
+
+
+
+ on
+ off
+
+
+
diff --git a/src/api/app/models/bs_request_action.rb b/src/api/app/models/bs_request_action.rb
index 86aa33b78805..a54589900494 100644
--- a/src/api/app/models/bs_request_action.rb
+++ b/src/api/app/models/bs_request_action.rb
@@ -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(':')
diff --git a/src/api/app/models/configuration.rb b/src/api/app/models/configuration.rb
index 1f7846e568d4..36cdb2c9522d 100644
--- a/src/api/app/models/configuration.rb
+++ b/src/api/app/models/configuration.rb
@@ -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)
diff --git a/src/api/app/models/project.rb b/src/api/app/models/project.rb
index db79afd55f76..362c74845610 100644
--- a/src/api/app/models/project.rb
+++ b/src/api/app/models/project.rb
@@ -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
diff --git a/src/api/db/migrate/20140218174400_cleanup_empty_projects.rb b/src/api/db/migrate/20140218174400_cleanup_empty_projects.rb
new file mode 100644
index 000000000000..f1d78a9f045e
--- /dev/null
+++ b/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
diff --git a/src/api/db/migrate/20140219185200_disable_publish_for_branches.rb b/src/api/db/migrate/20140219185200_disable_publish_for_branches.rb
new file mode 100644
index 000000000000..f27450905a17
--- /dev/null
+++ b/src/api/db/migrate/20140219185200_disable_publish_for_branches.rb
@@ -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
diff --git a/src/api/db/structure.sql b/src/api/db/structure.sql
index 8b6a9fbb0ec9..c97f993f30d9 100644
--- a/src/api/db/structure.sql
+++ b/src/api/db/structure.sql
@@ -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;
@@ -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');
diff --git a/src/backend/BSXML.pm b/src/backend/BSXML.pm
index 3c078c1891f1..2c2534578a49 100644
--- a/src/backend/BSXML.pm
+++ b/src/backend/BSXML.pm
@@ -1471,6 +1471,8 @@ our $configuration = [
'http_proxy',
'no_proxy',
'theme',
+ 'cleanup_empty_projects',
+ 'disable_publish_for_branches',
[ 'schedulers' =>
[ 'arch' ],
],