Skip to content

Commit

Permalink
[api] log reason why a channel got added
Browse files Browse the repository at this point in the history
yes, the parameters should become a hash...
  • Loading branch information
adrianschroeter committed Jul 24, 2015
1 parent 9ed8e74 commit 4bae3b3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/api/app/models/channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,16 @@ def update_from_xml(xmlhash)
save
end

def branch_channel_package_into_project(project)
def branch_channel_package_into_project(project, comment=nil)
cp = self.package

# create a package container
tpkg = Package.new(:name => self.name, :title => cp.title, :description => cp.description)
project.packages << tpkg
tpkg.store
tpkg.store({comment: comment})

# branch sources
tpkg.branch_from(cp.project.name, cp.name)
tpkg.branch_from(cp.project.name, cp.name, nil, nil, comment)
tpkg.sources_changed

tpkg
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/models/channel_binary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ def self.find_by_project_and_package(project, package)
ChannelBinary.find_by_sql(['SELECT channel_binaries.* FROM channel_binaries LEFT JOIN channel_binary_lists ON channel_binary_lists.id = channel_binaries.channel_binary_list_id LEFT JOIN channels ON channel_binary_lists.channel_id = channels.id LEFT JOIN packages ON channels.package_id = packages.id WHERE (channel_binary_lists.project_id = ? and package = ? and packages.project_id IN (?))', project.id, package, maintained_projects])
end

def create_channel_package_into(project)
def create_channel_package_into(project, comment=nil)

channel = self.channel_binary_list.channel

# does it exist already? then just skip it
return nil if Package.exists_by_project_and_name(project.name, channel.name, follow_project_links: false, allow_remote_packages: false)

# create a channel package beside my package and return that
return channel.branch_channel_package_into_project(project)
return channel.branch_channel_package_into_project(project, comment)
end

def to_axml_id(opts={})
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ def add_channels(mode=nil)
# main package
ChannelBinary.find_by_project_and_package(project_name, opkg.name).each do |cb|
next if mode == :skip_disabled and not cb.channel_binary_list.channel.is_active?
cpkg = cb.create_channel_package_into(self.project)
cpkg = cb.create_channel_package_into(self.project, "Listed in #{project_name} #{opkg.name}")
next unless cpkg
cpkg.channels.first.add_channel_repos_to_project(cpkg, mode)
end
Expand Down

0 comments on commit 4bae3b3

Please sign in to comment.