class Fastlane::Actions::GitCommitAction

Public Class Methods

authors() click to toggle source
# File fastlane/lib/fastlane/actions/git_commit.rb, line 60
def self.authors
  ["KrauseFx"]
end
available_options() click to toggle source
# File fastlane/lib/fastlane/actions/git_commit.rb, line 33
def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :path,
                                 description: "The file(s) or directory(ies) you want to commit. You can pass an array of multiple file-paths or fileglobs \"*.txt\" to commit all matching files. The files already staged but not specified and untracked files won't be committed",
                                 type: Array),
    FastlaneCore::ConfigItem.new(key: :message,
                                 description: "The commit message that should be used"),
    FastlaneCore::ConfigItem.new(key: :skip_git_hooks,
                                 description: "Set to true to pass `--no-verify` to git",
                                 default_value: false,
                                 type: Boolean,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :allow_nothing_to_commit,
                                 description: "Set to true to allow commit without any git changes in the files you want to commit",
                                 default_value: false,
                                 type: Boolean,
                                 optional: true)
  ]
end
category() click to toggle source
# File fastlane/lib/fastlane/actions/git_commit.rb, line 77
def self.category
  :source_control
end
description() click to toggle source

@!group Documentation

# File fastlane/lib/fastlane/actions/git_commit.rb, line 29
def self.description
  "Directly commit the given file with the given message"
end
example_code() click to toggle source
# File fastlane/lib/fastlane/actions/git_commit.rb, line 68
def self.example_code
  [
    'git_commit(path: "./version.txt", message: "Version Bump")',
    'git_commit(path: ["./version.txt", "./changelog.txt"], message: "Version Bump")',
    'git_commit(path: ["./*.txt", "./*.md"], message: "Update documentation")',
    'git_commit(path: ["./*.txt", "./*.md"], message: "Update documentation", skip_git_hooks: true)'
  ]
end
is_supported?(platform) click to toggle source
# File fastlane/lib/fastlane/actions/git_commit.rb, line 64
def self.is_supported?(platform)
  true
end
output() click to toggle source
# File fastlane/lib/fastlane/actions/git_commit.rb, line 53
def self.output
end
return_value() click to toggle source
# File fastlane/lib/fastlane/actions/git_commit.rb, line 56
def self.return_value
  nil
end
run(params) click to toggle source
# File fastlane/lib/fastlane/actions/git_commit.rb, line 4
def self.run(params)
  paths = params[:path].map(&:shellescape).join(' ')

  skip_git_hooks = params[:skip_git_hooks] ? '--no-verify' : ''

  if params[:allow_nothing_to_commit]
    # Here we check if the path passed in parameter contains any modification
    # and we skip the `git commit` command if there is none.
    # That means you can have other files modified that are not in the path parameter
    # and still make use of allow_nothing_to_commit.
    repo_clean = Actions.sh("git status #{paths} --porcelain").empty?
    UI.success("Nothing to commit, working tree clean ✅.") if repo_clean
    return if repo_clean
  end

  command = "git commit -m #{params[:message].shellescape} #{paths} #{skip_git_hooks}".strip
  result = Actions.sh(command)
  UI.success("Successfully committed \"#{params[:path]}\" 💾.")
  return result
end