Sha256: 4eff32ba58bfe3e535732929c3a73d3f7c199ae486585c157f25791e238a2b5e

Contents?: true

Size: 1.24 KB

Versions: 15

Compression:

Stored size: 1.24 KB

Contents

require "geny/error"

module Geny
  module Actions
    # Utilities for interacting with a git repo
    class Git
      # Create a new Git
      # @param shell [Shell]
      def initialize(shell:)
        @shell = shell
      end

      # Initialize a new git repo
      # @raise [ExitError]
      #
      # @example
      #   git.init
      def init(**opts)
        @shell.run("git", "init", out: File::NULL, **opts)
      end

      # Stage files to be committed
      # @param files [Array<String>]
      # @raise [ExitError]
      #
      # @example
      #   git.add
      #   git.add files: ["Gemfile"]
      def add(files: ["."], **opts)
        @shell.run("git", "add", *files, out: File::NULL, **opts)
      end

      # Commit staged files
      # @param message [String]
      # @raise [ExitError]
      #
      # @example
      #   git.commit message: "First commit"
      def commit(message:, **opts)
        @shell.run("git", "commit", "-m", message, out: File::NULL, **opts)
      end

      # Get the path to the current git repo
      # @raise [ExitError]
      #
      # @example
      #   git.repo_path #=> "/path/to/repo"
      def repo_path(**opts)
        @shell.capture("git", "rev-parse", "--show-toplevel", **opts)
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
geny-2.5.2 lib/geny/actions/git.rb
geny-2.5.1 lib/geny/actions/git.rb
geny-2.5.0 lib/geny/actions/git.rb
geny-2.4.0 lib/geny/actions/git.rb
geny-2.3.0 lib/geny/actions/git.rb
geny-2.2.0 lib/geny/actions/git.rb
geny-2.1.4 lib/geny/actions/git.rb
geny-2.1.3 lib/geny/actions/git.rb
geny-2.1.2 lib/geny/actions/git.rb
geny-2.1.1 lib/geny/actions/git.rb
geny-2.1.0 lib/geny/actions/git.rb
geny-2.0.0 lib/geny/actions/git.rb
geny-1.0.1 lib/geny/actions/git.rb
geny-1.0.0 lib/geny/actions/git.rb
geny-0.1.0 lib/geny/actions/git.rb