Class: BuildTool::VCS::Bazar
Overview
Implementation for the bzr version control system.
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.bzr_available? ⇒ Boolean
Is the git executable available?.
Instance Method Summary collapse
-
#bzr(command, wd = local_path, &block) ⇒ Object
Execute
command
in directorywd
and yield every line of output. -
#checkedout? ⇒ Boolean
METHODS.
-
#clone ⇒ Object
Initialize the local repository.
-
#fetch(verbose = false) ⇒ Object
Fetch from
repository
. - #fetching_supported? ⇒ Boolean
-
#initialize(config) ⇒ Bazar
constructor
A new instance of Bazar.
-
#name ⇒ Object
ATTRIBUTES.
- #ready_for_fetch ⇒ Object
- #rebase(verbose = false) ⇒ Object
Methods inherited from Base
#apply_patches_after_rebase?, #check_for_sshkey, #configure, #gc, #local_path, #local_path_exist?, #patches_supported?, #prepare_for_fetch, #prepare_for_rebase, #ready_for_rebase, #recipe
Constructor Details
#initialize(config) ⇒ Bazar
Returns a new instance of Bazar.
42 43 44 45 |
# File 'lib/build-tool/vcs/bazar.rb', line 42 def initialize( config ) super( config ) @vcs = nil end |
Class Method Details
.bzr_available? ⇒ Boolean
Is the git executable available?
85 86 87 88 89 90 |
# File 'lib/build-tool/vcs/bazar.rb', line 85 def self.bzr_available?() return @bzr_available unless @bzr_available.nil? %x( bzr --version 2>&1 ) @bzr_available = $?.success? return @bzr_available end |
Instance Method Details
#bzr(command, wd = local_path, &block) ⇒ Object
Execute command
in directory wd
and yield every line of output.
137 138 139 |
# File 'lib/build-tool/vcs/bazar.rb', line 137 def bzr( command, wd = local_path, &block ) rc = self.class.execute "bzr #{command}", wd, &block end |
#checkedout? ⇒ Boolean
METHODS
62 63 64 65 66 67 68 |
# File 'lib/build-tool/vcs/bazar.rb', line 62 def checkedout? return false if !local_path_exist? if !Pathname.new( local_path ).join( ".bzr" ).exist? raise Base::VcsError, "Checkout path #{local_path} is not a bazar repo!" end return true end |
#clone ⇒ Object
Initialize the local repository
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/build-tool/vcs/bazar.rb', line 71 def clone # Check if path exists if local_path_exist? raise BazarError, "Failed to create repository at '#{local_path}': Path exists" end FileUtils.mkdir_p Pathname.new( local_path ).dirname if ! $noop # Initialize the repository if bzr( "branch #{config.url} #{local_path}", Pathname.new( local_path ).dirname) != 0 raise BazarError, "Error while initializing the repo `bzr branch #{config.url} #{local_path}'`: #{$?}" end end |
#fetch(verbose = false) ⇒ Object
Fetch from repository
Initializes the local clone if it does not exist.
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/build-tool/vcs/bazar.rb', line 115 def fetch( verbose = false ) if !checkedout? and !$noop clone end if verbose cmd = "update -v" else cmd = "update" end rc = bzr( cmd ) do |line| logger.info( line ) end if rc != 0 raise BazarError, "Error while update: #{rc}" end end |
#fetching_supported? ⇒ Boolean
54 55 56 |
# File 'lib/build-tool/vcs/bazar.rb', line 54 def fetching_supported? false end |
#name ⇒ Object
ATTRIBUTES
50 51 52 |
# File 'lib/build-tool/vcs/bazar.rb', line 50 def name "bazar" end |
#ready_for_fetch ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/build-tool/vcs/bazar.rb', line 92 def ready_for_fetch if not self.class.bzr_available? logger.error( "#{config.module.name}: Calling `bzr` failed!" ) return false end if checkedout? # Check if the index is dirty. if bzr( "diff" ) != 0 logger.info( "#{config.module.name}: Local changes will prevent the update." ) bzr( "status --short --versioned" ) do |line| logger.info line.chomp end return false end end return true end |
#rebase(verbose = false) ⇒ Object
141 142 143 144 |
# File 'lib/build-tool/vcs/bazar.rb', line 141 def rebase( verbose = false ) # Rebasing is not supported 0 end |