Sha256: 74244de6cee3140d9b89297678d2cf0c60d3c69b45d9a0ff3622949c6736a59e

Contents?: true

Size: 937 Bytes

Versions: 3

Compression:

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

3 entries across 3 versions & 1 rubygems

Version Path
gemsmith-14.1.2 lib/gemsmith/generators/git.rb
gemsmith-14.1.1 lib/gemsmith/generators/git.rb
gemsmith-14.1.0 lib/gemsmith/generators/git.rb