lib/autobuild/import/git.rb
# Updates the git alternates file in the already checked out package to
# match {#alternates}
#
# @param [Package] package the already checked-out package
# @return [void]
Updates the git alternates file in the already checked out package to
match {#alternates}
Updates the git alternates file in the already checked out package to match { #alternates }
def update_alternates(package)
            alternates_path = File.join(git_dir(package, false), 'objects', 'info', 'alternates')
            current_alternates =
                if File.file?(alternates_path)
                    File.readlines(alternates_path).map(&:strip).find_all { |l| !l.empty? }
                else Array.new
                end
            alternates = each_alternate_path(package).map do |path|
                File.join(path, 'objects')
            end
            if current_alternates.sort != alternates.sort
                package.warn "%s: the list of git alternates listed in the repository differs from the one set up in autobuild."
                package.warn "%s: I will update, but that is dangerous"
                package.warn "%s: using git alternates is for advanced users only, who know git very well."
                package.warn "%s: Don't complain if something breaks"
            end
            if alternates.empty?
                FileUtils.rm_f alternates_path
            else
                File.open(alternates_path, 'w') do |io|
                    io.write alternates.join("\n")
                end
            end
        end
def update_alternates ( package ) alternates_path = File . join ( git_dir ( package , false ) , 'objects' , 'info' , 'alternates' ) current_alternates = if File . file? ( alternates_path ) File . readlines ( alternates_path ) . map ( & :strip ) . find_all { | l | ! l . empty? } else Array . new end alternates = each_alternate_path ( package ) . map do | path | File . join ( path , 'objects' ) end if current_alternates . sort != alternates . sort package . warn "%s: the list of git alternates listed in the repository differs from the one set up in autobuild." package . warn "%s: I will update, but that is dangerous" package . warn "%s: using git alternates is for advanced users only, who know git very well." package . warn "%s: Don't complain if something breaks" end if alternates . empty? FileUtils . rm_f alternates_path else File . open ( alternates_path , 'w' ) do | io | io . write alternates . join ( "\n" ) end end end
Updates the git alternates file in the already checked out package to
match {#alternates}
Updates the git alternates file in the already checked out package to match { #alternates }
# Warn that something is fishy, but assume that the user knows # what he is doing
None
void
package
<not_specific>
<not_specific>
package the already checked-out package
package the already checked - out package