Sha256: a49450e79e94ea567549d97281ba13b5cb9773e7589d70528d569f87f454612e

Contents?: true

Size: 1.37 KB

Versions: 36

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

require 'avm/scms/commit'
require 'eac_ruby_utils/core_ext'

module Avm
  module Git
    module Scms
      class Git < ::Avm::Scms::Base
        module Commits
          # @return [Avm::Git::Scms::Git::Commit,nil]
          def commit(source)
            if source.is_a?(::Avm::Git::Scms::Git::Commit)
              return source if source.git_repo == git_repo

              raise 'Not same Git repository'
            end
            git_repo.commitize(source).if_present do |v|
              ::Avm::Git::Scms::Git::Commit.new(self, v)
            end
          end

          # @param commit_info [Avm::Scms::CommitInfo]
          # @return [Avm::Git::Scms::Git::Commit,nil]
          def commit_if_change(commit_info = nil)
            tracker = ::Avm::Git::Scms::Git::ChangeTracker.new(self, commit_info)
            tracker.start
            yield
            tracker.stop
          end

          # @return [Avm::Git::Scms::Git::Commit]
          def head_commit
            commit(git_repo.head)
          end

          # @param commit_info [Avm::Scms::CommitInfo]
          # @return [Avm::Git::Scms::Git::Commit]
          def reset_and_commit(commit_to_reset, commit_info)
            git_repo.command('reset', '--soft', commit(commit_to_reset).git_commit.id).execute!
            commit_dirty(commit_info)
          end
        end
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 2 rubygems

Version Path
avm-git-0.18.0 lib/avm/git/scms/git/commits.rb
eac_tools-0.94.0 sub/avm-git/lib/avm/git/scms/git/commits.rb
avm-git-0.17.0 lib/avm/git/scms/git/commits.rb
eac_tools-0.86.5 sub/avm-git/lib/avm/git/scms/git/commits.rb
avm-git-0.16.0 lib/avm/git/scms/git/commits.rb
eac_tools-0.86.4 sub/avm-git/lib/avm/git/scms/git/commits.rb
eac_tools-0.86.3 sub/avm-git/lib/avm/git/scms/git/commits.rb
avm-git-0.15.0 lib/avm/git/scms/git/commits.rb
eac_tools-0.86.2 sub/avm-git/lib/avm/git/scms/git/commits.rb
eac_tools-0.84.0 sub/avm-git/lib/avm/git/scms/git/commits.rb
eac_tools-0.83.0 sub/avm-git/lib/avm/git/scms/git/commits.rb
eac_tools-0.82.0 sub/avm-git/lib/avm/git/scms/git/commits.rb
avm-git-0.14.0 lib/avm/git/scms/git/commits.rb
eac_tools-0.81.0 sub/avm-git/lib/avm/git/scms/git/commits.rb
eac_tools-0.80.0 sub/avm-git/lib/avm/git/scms/git/commits.rb
eac_tools-0.79.0 sub/avm-git/lib/avm/git/scms/git/commits.rb
eac_tools-0.78.0 sub/avm-git/lib/avm/git/scms/git/commits.rb
eac_tools-0.77.1 sub/avm-git/lib/avm/git/scms/git/commits.rb
eac_tools-0.77.0 sub/avm-git/lib/avm/git/scms/git/commits.rb
eac_tools-0.76.1 sub/avm-git/lib/avm/git/scms/git/commits.rb