Sha256: 455a6a9d0d05cb9d4b1c719535f1cbf0988758e6131bcc6abbcd2f077ffec782

Contents?: true

Size: 1.39 KB

Versions: 53

Compression:

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

53 entries across 53 versions & 1 rubygems

Version Path
canzea-0.1.72 lib/commands/config-git-commit.rb
canzea-0.1.71 lib/commands/config-git-commit.rb
canzea-0.1.70 lib/commands/config-git-commit.rb
canzea-0.1.68 lib/commands/config-git-commit.rb
canzea-0.1.67 lib/commands/config-git-commit.rb
canzea-0.1.66 lib/commands/config-git-commit.rb
canzea-0.1.64 lib/commands/config-git-commit.rb
canzea-0.1.63 lib/commands/config-git-commit.rb
canzea-0.1.62 lib/commands/config-git-commit.rb
canzea-0.1.61 lib/commands/config-git-commit.rb
canzea-0.1.60 lib/commands/config-git-commit.rb
canzea-0.1.59 lib/commands/config-git-commit.rb
canzea-0.1.58 lib/commands/config-git-commit.rb
canzea-0.1.57 lib/commands/config-git-commit.rb
canzea-0.1.56 lib/commands/config-git-commit.rb
canzea-0.1.55 lib/commands/config-git-commit.rb
canzea-0.1.54 lib/commands/config-git-commit.rb
canzea-0.1.53 lib/commands/config-git-commit.rb
canzea-0.1.52 lib/commands/config-git-commit.rb
canzea-0.1.51 lib/commands/config-git-commit.rb