Sha256: da7c259d7fe134dfdc1938fddc9b92f31a05a6a5d51ce956239b0026b886d9ea

Contents?: true

Size: 1.41 KB

Versions: 18

Compression:

Stored size: 1.41 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

        if (File.exists?(sourcePath))
            dest = "#{gitRoot}/config#{Pathname.new(sourcePath).realpath}"
        else
            dest = "#{gitRoot}/config#{sourcePath}"
        end
        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, 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

18 entries across 18 versions & 1 rubygems

Version Path
canzea-0.1.94 lib/commands/config-git-commit.rb
canzea-0.1.93 lib/commands/config-git-commit.rb
canzea-0.1.91 lib/commands/config-git-commit.rb
canzea-0.1.90 lib/commands/config-git-commit.rb
canzea-0.1.89 lib/commands/config-git-commit.rb
canzea-0.1.88 lib/commands/config-git-commit.rb
canzea-0.1.87 lib/commands/config-git-commit.rb
canzea-0.1.86 lib/commands/config-git-commit.rb
canzea-0.1.85 lib/commands/config-git-commit.rb
canzea-0.1.84 lib/commands/config-git-commit.rb
canzea-0.1.83 lib/commands/config-git-commit.rb
canzea-0.1.82 lib/commands/config-git-commit.rb
canzea-0.1.81 lib/commands/config-git-commit.rb
canzea-0.1.80 lib/commands/config-git-commit.rb
canzea-0.1.78 lib/commands/config-git-commit.rb
canzea-0.1.77 lib/commands/config-git-commit.rb
canzea-0.1.76 lib/commands/config-git-commit.rb
canzea-0.1.74 lib/commands/config-git-commit.rb