Class: BuildTool::VCS::Base

Inherits:
Object
  • Object
show all
Includes:
MJ::Tools::SubProcess
Defined in:
lib/build-tool/vcs/base.rb

Overview

Base class for Version Control System implementations

Direct Known Subclasses

Archive, Bazar, Git, GitSvn, Mercurial, Svn

Defined Under Namespace

Classes: VcsError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Base

# Create a repository



48
49
50
# File 'lib/build-tool/vcs/base.rb', line 48

def initialize( config )
    @config = config
end

Instance Attribute Details

#configObject (readonly)

ATTRIBUTES



55
56
57
# File 'lib/build-tool/vcs/base.rb', line 55

def config
  @config
end

Instance Method Details

#apply_patches_after_rebase?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/build-tool/vcs/base.rb', line 63

def apply_patches_after_rebase?
    false
end

#check_for_sshkey(key = nil) ⇒ Object



86
87
88
89
90
91
92
93
# File 'lib/build-tool/vcs/base.rb', line 86

def check_for_sshkey( key = nil )
    if key and ! MJ::Tools::SSH::has_key? key.file
        logger.info ""
        logger.info "#### Adding required ssh-key #{key.file} to ssh-agent."
        return MJ::Tools::SSH::add_key key.file
    end
    true
end

#configureObject



95
96
97
# File 'lib/build-tool/vcs/base.rb', line 95

def configure
    logger.debug "VCS #{name} did not implement configure!"
end

#gcObject

Collect garbage, do maintenance …



68
69
# File 'lib/build-tool/vcs/base.rb', line 68

def gc
end

#local_changesObject



157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/build-tool/vcs/base.rb', line 157

def local_changes
    if block_given?
        do_local_changes( &block )
    else
        r = []
        do_local_changes() do |c|
            r << c
        end
        if r == [ nil ]
            return nil
        end
        return r
    end
end

#local_pathObject

Raises:



71
72
73
74
75
# File 'lib/build-tool/vcs/base.rb', line 71

def local_path
    local_path = @config.local_path
    raise ConfigurationError, "#{self.class}.local_path not set" if local_path.nil?
    local_path
end

#local_path_exist?Boolean

checks if path exists and is a directory

Returns:

  • (Boolean)


82
83
84
# File 'lib/build-tool/vcs/base.rb', line 82

def local_path_exist?
    !local_path.nil? and File.exist? local_path and File.directory? local_path
end

#patches_supported?Boolean

CAPABILITIES

Returns:

  • (Boolean)


59
60
61
# File 'lib/build-tool/vcs/base.rb', line 59

def patches_supported?
    false
end

#prepare_for_fetchObject



99
100
101
# File 'lib/build-tool/vcs/base.rb', line 99

def prepare_for_fetch
    true
end

#prepare_for_rebaseObject



103
104
105
# File 'lib/build-tool/vcs/base.rb', line 103

def prepare_for_rebase
    true
end

#ready_for_fetchObject



107
108
109
# File 'lib/build-tool/vcs/base.rb', line 107

def ready_for_fetch
    true
end

#ready_for_rebaseObject



111
112
113
# File 'lib/build-tool/vcs/base.rb', line 111

def ready_for_rebase
    true
end

#recipeObject



115
116
117
# File 'lib/build-tool/vcs/base.rb', line 115

def recipe
    Application::instance.recipe
end

#remote_changes(&block) ⇒ Object



142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/build-tool/vcs/base.rb', line 142

def remote_changes( &block )
    if block_given?
        do_remote_changes( &block )
    else
        r = []
        do_remote_changes() do |c|
            r << c
        end
        if r == [ nil ]
            return nil
        end
        return r
    end
end