lib/autobuild/import/git.rb
# Fetches updates from the remote repository. Returns the remote commit
# ID on success, nil on failure. Expects the current directory to be the
# package's source directory.
Fetches updates from the remote repository. Returns the remote commit
ID on success, nil on failure. Expects the current directory to be the
package's source directory.
Fetches updates from the remote repository . Returns the remote commit ID on success nil on failure . Expects the current directory to be the package ' s source directory .
def fetch_remote(package)
            validate_importdir(package)
            git_dir = git_dir(package, false)
            git = [package, :import, Autobuild.tool('git'), '--git-dir', git_dir]
             Otherwise, do git fetch now
             Doing it now is better as it makes sure that we replace the
             configuration parameters only if the repository and branch are
             OK (i.e. we keep old working configuration instead)
            refspec = [branch || tag].compact
            Subprocess.run(*git, 'fetch', '--tags', repository, *refspec)
            update_remotes_configuration(package, :import)
             Now get the actual commit ID from the FETCH_HEAD file, and
             return it
            commit_id = if File.readable?( File.join(git_dir, 'FETCH_HEAD') )
                fetch_commit = File.readlines( File.join(git_dir, 'FETCH_HEAD') ).
                    delete_if { |l| l =~ /not-for-merge/ }
                if !fetch_commit.empty?
                    fetch_commit.first.split(/\s+/).first
                end
            end
             Update the remote tag if needs be
            if branch && commit_id
                Subprocess.run(*git, 'update-ref',
                               "-m", "updated by autobuild", "refs/remotes/{remote_name}/{remote_branch}", commit_id)
            end
            commit_id
        end
def fetch_remote ( package ) validate_importdir ( package ) git_dir = git_dir ( package , false ) git = [ package , :import , Autobuild . tool ( 'git' ) , '--git-dir' , git_dir ] refspec = [ branch || tag ] . compact Subprocess . run ( * git , 'fetch' , '--tags' , repository , * refspec ) update_remotes_configuration ( package , :import ) commit_id = if File . readable? ( File . join ( git_dir , 'FETCH_HEAD' ) ) fetch_commit = File . readlines ( File . join ( git_dir , 'FETCH_HEAD' ) ) . delete_if { | l | l =~ / not-for-merge / } if ! fetch_commit . empty? fetch_commit . first . split ( / \s + / ) . first end end if branch && commit_id Subprocess . run ( * git , 'update-ref' , "-m" , "updated by autobuild" , "refs/remotes/#{remote_name}/#{remote_branch}" , commit_id ) end commit_id end
Fetches updates from the remote repository.
Fetches updates from the remote repository .
# If we are checking out a specific commit, we don't know which # branch to refer to in git fetch. So, we have to set up the # remotes and call git fetch directly (so that all branches get # fetch) # # Otherwise, do git fetch now # # Doing it now is better as it makes sure that we replace the # configuration parameters only if the repository and branch are # OK (i.e. we keep old working configuration instead) # Now get the actual commit ID from the FETCH_HEAD file, and # return it # Update the remote tag if needs be
package
<not_specific>