Skip to content

Commit

Permalink
[ensure_git_status_clean] fix incorrect "ignored" param handling
Browse files Browse the repository at this point in the history
  • Loading branch information
revolter committed Jan 17, 2023
1 parent 99f6ca4 commit c8aa3c5
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fastlane/lib/fastlane/actions/ensure_git_status_clean.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class EnsureGitStatusCleanAction < Action
def self.run(params)
if params[:ignored]
ignored_mode = params[:ignored]
repo_status = Actions.sh("git status --porcelain --ignored #{ignored_mode}")
repo_status = Actions.sh("git status --porcelain --ignored='#{ignored_mode}'")
else
repo_status = Actions.sh("git status --porcelain")
end
Expand Down
41 changes: 41 additions & 0 deletions fastlane/spec/actions_specs/ensure_git_status_clean_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
context "when git status is not clean" do
before :each do
allow(Fastlane::Actions).to receive(:sh).with("git status --porcelain").and_return("M fastlane/lib/fastlane/actions/ensure_git_status_clean.rb")
allow(Fastlane::Actions).to receive(:sh).with("git status --porcelain --ignored='traditional'").and_return("M fastlane/lib/fastlane/actions/ensure_git_status_clean.rb\n!! .DS_Store\n!! fastlane/")
allow(Fastlane::Actions).to receive(:sh).with("git status --porcelain --ignored='no'").and_return("M fastlane/lib/fastlane/actions/ensure_git_status_clean.rb")
allow(Fastlane::Actions).to receive(:sh).with("git status --porcelain --ignored='matching'").and_return("M fastlane/lib/fastlane/actions/ensure_git_status_clean.rb\n!! .DS_Store\n!! fastlane/.DS_Store")
allow(Fastlane::Actions).to receive(:sh).with("git diff").and_return("+ \"this is a new line\"")
end

Expand Down Expand Up @@ -73,6 +76,44 @@
end
end
end

context "with ignored mode" do
context "traditional" do
it "outputs error message with ignored files" do
expect(FastlaneCore::UI).to receive(:user_error!).with("Git repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first.\nUncommitted changes:\nM fastlane/lib/fastlane/actions/ensure_git_status_clean.rb\n!! .DS_Store\n!! fastlane/")
Fastlane::FastFile.new.parse("lane :test do
ensure_git_status_clean(show_uncommitted_changes: true, ignored: 'traditional')
end").runner.execute(:test)
end
end

context "no" do
it "outputs error message without ignored files" do
expect(FastlaneCore::UI).to receive(:user_error!).with("Git repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first.\nUncommitted changes:\nM fastlane/lib/fastlane/actions/ensure_git_status_clean.rb")
Fastlane::FastFile.new.parse("lane :test do
ensure_git_status_clean(show_uncommitted_changes: true, ignored: 'no')
end").runner.execute(:test)
end
end

context "matching" do
it "outputs error message with ignored files" do
expect(FastlaneCore::UI).to receive(:user_error!).with("Git repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first.\nUncommitted changes:\nM fastlane/lib/fastlane/actions/ensure_git_status_clean.rb\n!! .DS_Store\n!! fastlane/.DS_Store")
Fastlane::FastFile.new.parse("lane :test do
ensure_git_status_clean(show_uncommitted_changes: true, ignored: 'matching')
end").runner.execute(:test)
end
end
end

context "without ignored mode" do
it "outputs error message without ignored files" do
expect(FastlaneCore::UI).to receive(:user_error!).with("Git repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first.\nUncommitted changes:\nM fastlane/lib/fastlane/actions/ensure_git_status_clean.rb")
Fastlane::FastFile.new.parse("lane :test do
ensure_git_status_clean(show_uncommitted_changes: true)
end").runner.execute(:test)
end
end
end
end
end
Expand Down

0 comments on commit c8aa3c5

Please sign in to comment.