Sha256: 6f8d19e465398689a3b8c5a010a1aa1196e50a8f916e78f6f897a3bc302a222f

Contents?: true

Size: 1.29 KB

Versions: 17

Compression:

Stored size: 1.29 KB

Contents

require "git"
require "fileutils"
require "pathname"

class ConfigGitCommit
    def do(gitRoot, sourcePath, template, parameters = {})
        # if file exists on file system and does not exist in gitRoot, then commit the "oem" file

        dest = "#{gitRoot}/config#{Pathname.new(sourcePath).realpath}"
        puts "Writing to #{dest}"

        if (File.exist?(dest) == false and File.exist?(sourcePath))
            FileUtils.mkdir_p Pathname.new(dest).dirname
            FileUtils.cp sourcePath, dest

            puts "Recording in repo the default file first: #{sourcePath}"
            g = Git.init(gitRoot)
            g.add(:all=>true)
            g.commit("Original default #{sourcePath}")
        end

        if template
            puts "Processing template #{template}"
            FileUtils.mkdir_p Pathname.new(sourcePath).dirname
            t = Template.new
            t.processAndWriteToFile template, sourcePath, JSON.parse(parameters)
        end
        FileUtils.mkdir_p Pathname.new(dest).dirname
        FileUtils.cp sourcePath, dest

        g = Git.init(gitRoot)
        g.add(:all=>true)
        puts g.status.changed.size() + g.status.added.size()
        if (g.status.changed.size() > 0 or g.status.added.size() > 0)
            g.commit("Config update #{sourcePath}")
        end
    end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
canzea-0.1.16 lib/commands/config-git-commit.rb
canzea-0.1.15 lib/commands/config-git-commit.rb
canzea-0.1.14 lib/commands/config-git-commit.rb
canzea-0.1.13 lib/commands/config-git-commit.rb
canzea-0.1.12 lib/commands/config-git-commit.rb
canzea-0.1.11 lib/commands/config-git-commit.rb
canzea-0.1.10 lib/commands/config-git-commit.rb
canzea-0.1.9 lib/commands/config-git-commit.rb
canzea-0.1.8 lib/commands/config-git-commit.rb
canzea-0.1.7 lib/commands/config-git-commit.rb
canzea-0.1.6 lib/commands/config-git-commit.rb
canzea-0.1.5 lib/commands/config-git-commit.rb
canzea-0.1.4 lib/commands/config-git-commit.rb
canzea-0.1.3 lib/commands/config-git-commit.rb
canzea-0.1.2 lib/commands/config-git-commit.rb
canzea-0.1.1 lib/commands/config-git-commit.rb
canzea-0.1.0 lib/commands/config-git-commit.rb