class Archlinux::Git

this is a get class; it should respond to update and clone

Attributes

config[RW]
dir[RW]
logdir[RW]
url[W]

Public Class Methods

new(dir, url: nil, logdir: nil, config: Archlinux.config) click to toggle source
# File lib/aur/makepkg.rb, line 14
def initialize(dir, url: nil, logdir: nil, config: Archlinux.config)
        @dir=Pathname.new(dir)
        @url=url
        @config=config
        @logdir=logdir
end

Public Instance Methods

call(*args,**opts,&b) click to toggle source
# File lib/aur/makepkg.rb, line 26
def call(*args,**opts,&b)
        opts[:method]||=:sh
        @dir.chdir do
                @config.launch(:git, *args, **opts, &b)
        end
end
clone(url: self.url, logdir: nil) click to toggle source
# File lib/aur/makepkg.rb, line 77
def clone(url: self.url, logdir: nil)
        if do_clone(url)
                (logdir+"!#{@dir.basename}").on_ln_s(@dir.realpath) if logdir
        else
                SH.logger.error("Error in cloning #{url} to #{@dir}")
        end
end
do_clone(url) click to toggle source
# File lib/aur/makepkg.rb, line 63
def do_clone(url)
        #we cannot call 'call' here because the folder does not yet exist
        suc, _r=@config.launch(:git, "clone", url, @dir, method: :sh)
        suc
end
do_update() click to toggle source
# File lib/aur/makepkg.rb, line 51
def do_update
        # we need to hard reset, because vercmp may have changed our PKGBUILD
        # todo: only reset when there is an update?
        # lets try with a theirs merge strat
        # call("reset", "--hard")
        # -> still does not work: error: Your local changes to the following files would be overwritten by merge: PKGBUILD
        ## suc, _r=call("pull", "-X", "theirs")
        call("reset", "--hard")
        suc, _r=call("pull")
        suc
end
done_build() click to toggle source
# File lib/aur/makepkg.rb, line 37
def done_build
        call('branch', '-f', 'aur_build', 'HEAD')
end
done_view() click to toggle source

callbacks called by makepkg

# File lib/aur/makepkg.rb, line 34
def done_view
        call('branch', '-f', 'aur_view', 'HEAD')
end
update(logdir: nil) click to toggle source
# File lib/aur/makepkg.rb, line 69
def update(logdir: nil)
        if do_update
                write_patch(logdir) if logdir
        else
                SH.logger.error("Error in updating #{@dir}")
        end
end
url() click to toggle source
# File lib/aur/makepkg.rb, line 21
def url
        url=URI.parse(@url)
        url.relative? ? @config[:aur_url]+@url.to_s+".git" : url
end
write_patch(logdir) click to toggle source
# File lib/aur/makepkg.rb, line 41
def write_patch(logdir)
        (logdir+"#{@dir.basename}").on_ln_s(@dir.realpath, rm: :symlink)
        if call("rev-parse", "--verify", "aur_view", method: :run_success, quiet: true)
                SH::VirtualFile.new("orderfile", "PKGBUILD").create(true) do |tmp|
                        patch=call("diff", "-O#{tmp}", "aur_view", "HEAD", method: :run_simple)
                        (logdir+"#{@dir.basename}.patch").write(patch) unless patch.empty?
                end
        end
end