Method: FalkorLib::Bootstrap.versionfile

Defined in:
lib/falkorlib/bootstrap/base.rb

.versionfile(dir = Dir.pwd, options = {}) ⇒ Object

versionfile ###### Bootstrap a VERSION file at the root of a project Supported options:

  • :file [string] filename

  • :version [string] version to mention in the file



241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/falkorlib/bootstrap/base.rb', line 241

def versionfile(dir = Dir.pwd, options = {})
  file    = (options[:file])    ? options[:file]    : 'VERSION'
  version = (options[:version]) ? options[:version] : '0.0.0'
  info " ==> bootstrapping a VERSION file"
  path = normalized_path(dir)
  path = FalkorLib::Git.rootdir(path) if FalkorLib::Git.init?(path)
  unless Dir.exist?( path )
    warning "The directory #{path} does not exists and will be created"
    really_continue?
    FileUtils.mkdir_p path
  end
  versionfile = File.join(path, file)
  if File.exist?( versionfile )
    puts "  ... not overwriting the #{file} file which already exists"
  else
    FalkorLib::Versioning.set_version(version, path, :type => 'file',
                                      :source => { :filename => file })
    Dir.chdir( path ) do
      run %( git tag #{options[:tag]} ) if options[:tag]
    end
  end

  # unless File.exists?( versionfile )
  #     run %{  echo "#{version}" > #{versionfile} }
  #     if FalkorLib::Git.init?(path)
  #         FalkorLib::Git.add(versionfile, "Initialize #{file} file")
  #         Dir.chdir( path ) do
  #             run %{ git tag #{options[:tag]} } if options[:tag]
  #         end
  #     end
  # else
  #     puts "  ... not overwriting the #{file} file which already exists"
  # end
end