Sha256: 78995ecce6c1818e2d2e8341511e489451c539042996fab78b124222e22847d4

Contents?: true

Size: 1.71 KB

Versions: 29

Compression:

Stored size: 1.71 KB

Contents

module HybridPlatformsConductor

  module HpcPlugins

    module Test

      # Check that the repository is having a Git linear strategy on master.
      class LinearStrategy < HybridPlatformsConductor::Test

        # Number of seconds of the period after which we tolerate non-linear history in git
        LOOKING_PERIOD = 6 * 31 * 24 * 60 * 60 # 6 months

        # Check my_test_plugin.rb.sample documentation for signature details.
        def test_on_platform
          _exit_status, stdout, _stderr = @cmd_runner.run_cmd(
            "cd #{@platform.repository_path} && git --no-pager log --merges --pretty=format:\"%H\"",
            log_to_stdout: log_debug?
          )
          stdout.split("\n").each do |merge_commit_id|
            _exit_status, stdout, _stderr = @cmd_runner.run_cmd(<<~EO_BASH, log_to_stdout: log_debug?, no_exception: true, expected_code: [0, 1])
              cd #{@platform.repository_path} && \
              git --no-pager log \
                $(git merge-base \
                  --octopus \
                  $(git --no-pager log #{merge_commit_id} --max-count 1 --pretty=format:\"%P\") \
                )..#{merge_commit_id} \
                --pretty=format:\"%H\" \
                --graph \
              | grep '|'
            EO_BASH
            next if stdout.empty?

            _exit_status, stdout, _stderr = @cmd_runner.run_cmd(
              "cd #{@platform.repository_path} && git --no-pager log #{merge_commit_id} --pretty=format:%aI",
              log_to_stdout: log_debug?
            )
            error "Git history is not linear because of Merge commit #{merge_commit_id}" if Time.now - Time.parse(stdout.strip) < LOOKING_PERIOD
          end
        end

      end

    end

  end

end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
hybrid_platforms_conductor-33.9.2 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-33.9.1 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-33.9.0 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-33.8.4 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-33.8.3 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-33.8.2 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-33.8.1 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-33.8.0 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-33.7.4 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-33.7.3 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-33.7.2 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-33.7.1 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-33.7.0 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-33.6.0 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-33.5.1 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-33.5.0 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-33.4.0 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-33.3.0 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-33.2.4 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-33.2.3 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb