Sha256: 3e57d4be65874c0cf245c7553f1ab1b4a8eb04c6083cd7832f37f645667e9f54

Contents?: true

Size: 934 Bytes

Versions: 1

Compression:

Stored size: 934 Bytes

Contents

# frozen_string_literal: true

require "open3"

module Gemsmith
  module Generators
    # Generates Git support.
    class Git < Base
      def initialize cli, configuration: {}, shell: Open3
        super cli, configuration: configuration
        @shell = shell
      end

      def run
        create_ignore_file
        create_repository
      end

      private

      attr_reader :shell

      def create_ignore_file
        template "%gem_name%/.gitignore.tt"
      end

      def create_repository
        create_commit "Added gem skeleton",
                      "Built with [#{Identity.label}](#{Identity.url}) #{Identity.version}."
      end

      def create_commit subject, body
        Dir.chdir gem_root do
          shell.capture3 "git init"
          shell.capture3 "git add ."
          shell.capture3 %(git commit --all --no-verify --message "#{subject}" --message "#{body}")
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gemsmith-14.0.2 lib/gemsmith/generators/git.rb