Sha256: 4f857d154320a871698baaeaad535fdc6032784bcc89ef266b383f7698b8ddad

Contents?: true

Size: 1.68 KB

Versions: 39

Compression:

Stored size: 1.68 KB

Contents

module Fastlane
  module Actions
    module SharedValues
      GIT_REPO_WAS_CLEAN_ON_START = :GIT_REPO_WAS_CLEAN_ON_START
    end

    # Raises an exception and stop the lane execution if the repo is not in a clean state
    class EnsureGitStatusCleanAction < Action
      def self.run(params)
        repo_clean = `git status --porcelain`.empty?

        if repo_clean
          UI.success('Git status is clean, all good! 💪')
          Actions.lane_context[SharedValues::GIT_REPO_WAS_CLEAN_ON_START] = true
        else
          UI.user_error!("Git repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first.")
        end
      end

      def self.description
        "Raises an exception if there are uncommitted git changes"
      end

      def self.details
        [
          'A sanity check to make sure you are working in a repo that is clean. Especially',
          'useful to put at the beginning of your Fastfile in the `before_all` block, if',
          'some of your other actions will touch your filesystem, do things to your git repo,',
          'or just as a general reminder to save your work. Also needed as a prerequisite for',
          'some other actions like `reset_git_repo`.'
        ].join("\n")
      end

      def self.output
        [
          ['GIT_REPO_WAS_CLEAN_ON_START', 'Stores the fact that the git repo was clean at some point']
        ]
      end

      def self.author
        "lmirosevic"
      end

      def self.example_code
        ['ensure_git_status_clean']
      end

      def self.category
        :source_control
      end

      def self.is_supported?(platform)
        true
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
fastlane-2.29.0.beta.20170421010107 fastlane/lib/fastlane/actions/ensure_git_status_clean.rb
fastlane-2.28.2 fastlane/lib/fastlane/actions/ensure_git_status_clean.rb
fastlane-2.28.1 fastlane/lib/fastlane/actions/ensure_git_status_clean.rb
fastlane-2.28.0 fastlane/lib/fastlane/actions/ensure_git_status_clean.rb
fastlane-2.28.0.beta.20170420010017 fastlane/lib/fastlane/actions/ensure_git_status_clean.rb
fastlane-2.28.0.beta.20170419010123 fastlane/lib/fastlane/actions/ensure_git_status_clean.rb
fastlane-2.28.0.beta.20170418010021 fastlane/lib/fastlane/actions/ensure_git_status_clean.rb
fastlane-2.28.0.beta.20170417010100 fastlane/lib/fastlane/actions/ensure_git_status_clean.rb
fastlane-2.28.0.beta.20170416010028 fastlane/lib/fastlane/actions/ensure_git_status_clean.rb
fastlane-2.28.0.beta.20170415010110 fastlane/lib/fastlane/actions/ensure_git_status_clean.rb
fastlane-2.27.0 fastlane/lib/fastlane/actions/ensure_git_status_clean.rb
fastlane-2.27.0.beta.20170414010035 fastlane/lib/fastlane/actions/ensure_git_status_clean.rb
fastlane-2.27.0.beta.20170413010117 fastlane/lib/fastlane/actions/ensure_git_status_clean.rb
fastlane-2.27.0.beta.20170412010036 fastlane/lib/fastlane/actions/ensure_git_status_clean.rb
fastlane-2.27.0.beta.20170411010118 fastlane/lib/fastlane/actions/ensure_git_status_clean.rb
fastlane-2.27.0.beta.20170410010020 fastlane/lib/fastlane/actions/ensure_git_status_clean.rb
fastlane-2.27.0.beta.20170409010031 fastlane/lib/fastlane/actions/ensure_git_status_clean.rb
fastlane-2.26.1 fastlane/lib/fastlane/actions/ensure_git_status_clean.rb
fastlane-2.27.0.beta.20170408010009 fastlane/lib/fastlane/actions/ensure_git_status_clean.rb