Skip to content

Commit

Permalink
disable_publish_for_branches: new configuration option
Browse files Browse the repository at this point in the history
OBS currently disables publishing for any new branch in order to avoid
using disk space and bandwidth to carry out publishing. For small private
installations, it can make sense to avoid that, and inherit the publish
flags from the parent project instead.

Bug: openSUSE#596
  • Loading branch information
smcv committed Feb 19, 2014
1 parent a1f3bb2 commit 0f508c3
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 6 deletions.
9 changes: 9 additions & 0 deletions docs/api/api/configuration.rng
Expand Up @@ -133,6 +133,15 @@
</choice> </choice>
</element> </element>
</optional> </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 --> <!-- webui only stuff -->
<optional> <optional>
Expand Down
3 changes: 2 additions & 1 deletion src/api/app/models/configuration.rb
Expand Up @@ -27,8 +27,9 @@ class Configuration < ActiveRecord::Base
:cleanup_after_days => nil, :cleanup_after_days => nil,
:theme => CONFIG['theme'], :theme => CONFIG['theme'],
:cleanup_empty_projects => nil, :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, :cleanup_empty_projects ] 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 class << self
def map_value(key, value) def map_value(key, value)
Expand Down
18 changes: 13 additions & 5 deletions src/api/app/models/project.rb
Expand Up @@ -1070,13 +1070,21 @@ def branch_to_repositories_from(project, pkg_to_enable, extend_names=nil)
end end
pkg_to_enable.enable_for_repository(repoName) if pkg_to_enable pkg_to_enable.enable_for_repository(repoName) if pkg_to_enable
end end
# take over flags, but explicit disable publishing by default and enable building. Ommiting also lock or we can not create packages # Take over flags, but enable building.
# By default, disable 'publish' to save space and bandwidth, but this
# can be turned off for small installations.
# Also omit 'lock' or we cannot create packages.
disable_publish_for_branches = ::Configuration.first.disable_publish_for_branches
project.flags.each do |f| project.flags.each do |f|
unless %w(build publish lock).include?(f.flag) next if %w(build lock).include?(f.flag)
self.flags.create(status: f.status, flag: f.flag, architecture: f.architecture, repo: f.repo) next if f.flag == 'publish' and disable_publish_for_branches
end
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 end
self.flags.create(:status => 'disable', :flag => 'publish') unless self.flags.find_by_flag_and_status( 'publish', 'disable' )
end end


def open_requests_with_project_as_source_or_target def open_requests_with_project_as_source_or_target
Expand Down
@@ -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
3 changes: 3 additions & 0 deletions src/api/db/structure.sql
Expand Up @@ -345,6 +345,7 @@ CREATE TABLE `configurations` (
`obs_url` varchar(255) COLLATE utf8_bin DEFAULT NULL, `obs_url` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`cleanup_after_days` int(11) DEFAULT NULL, `cleanup_after_days` int(11) DEFAULT NULL,
`cleanup_empty_projects` tinyint(1) DEFAULT '1', `cleanup_empty_projects` tinyint(1) DEFAULT '1',
`disable_publish_for_branches` tinyint(1) DEFAULT '1',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;


Expand Down Expand Up @@ -1445,6 +1446,8 @@ INSERT INTO schema_migrations (version) VALUES ('20140210114542');


INSERT INTO schema_migrations (version) VALUES ('20140218174400'); 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 ('21');


INSERT INTO schema_migrations (version) VALUES ('22'); INSERT INTO schema_migrations (version) VALUES ('22');
Expand Down
1 change: 1 addition & 0 deletions src/backend/BSXML.pm
Expand Up @@ -1472,6 +1472,7 @@ our $configuration = [
'no_proxy', 'no_proxy',
'theme', 'theme',
'cleanup_empty_projects', 'cleanup_empty_projects',
'disable_publish_for_branches',
[ 'schedulers' => [ 'schedulers' =>
[ 'arch' ], [ 'arch' ],
], ],
Expand Down

0 comments on commit 0f508c3

Please sign in to comment.