[ensure_git_status_clean] fix incorrect "ignored" param handling#20976
[ensure_git_status_clean] fix incorrect "ignored" param handling#20976
Conversation
| FastlaneCore::ConfigItem.new(key: :ignored, | ||
| env_name: "FL_ENSURE_GIT_STATUS_CLEAN_IGNORED_FILE", | ||
| description: "The flag whether to ignore file the git status if the repo is dirty", | ||
| description: "The ignored files handling mode if the repo is dirty. The available options are: 'traditional' (default), 'no' and 'matching'", |
There was a problem hiding this comment.
'traditional' is not the default. Currently the default is 'no'.
myhost:MY_PROJECT user$ git status --porcelain --ignored='traditional'
M ***/Info.plist
M Frameworks/***/Info.plist
M Frameworks/***/ios-arm64/***/Ast
M Frameworks/***/ios-arm64/***/Info.plist
!! .DS_Store
!! ***/Resources/assets/
!! Gemfile.lock
!! fastlane/README.md
!! fastlane/build/
!! fastlane/report.xml
vs.
myhost: MY_PROJECT user $ git status --porcelain --ignored='no'
M ***/Info.plist
M Frameworks/***/Info.plist
M Frameworks/***/ios-arm64/***/Ast
M Frameworks/***/ios-arm64/***/Info.plist
vs.
myhost: MY_PROJECT user $ bundle exec fastlane run ensure_git_status_clean
[14:10:46]: -------------------------------------
[14:10:46]: --- Step: ensure_git_status_clean ---
[14:10:46]: -------------------------------------
[14:10:46]: $ git status --porcelain
[14:10:47]: ▸ M ***/Info.plist
[14:10:47]: ▸ M Frameworks/***/Info.plist
[14:10:47]: ▸ M Frameworks/***/ios-arm64/***/Ast
[14:10:47]: ▸ M Frameworks/***/ios-arm64/***/Info.plist
There was a problem hiding this comment.
Oh, I misinterpreted the git documentation. It states that if you only use --ignored, without a value, traditional is used - meaning, it's the same as using --ignored=traditional.
There was a problem hiding this comment.
Could you please send me the output of git status --porcelain --ignored='matching' too?
There was a problem hiding this comment.
Sure, here you go:
myhost:MY_PROJECT jenkins$ git status --porcelain --ignored='matching'
M ***/Info.plist
M Frameworks/***/Info.plist
M Frameworks/***/ios-arm64/***/Ast
M Frameworks/***/ios-arm64/***/Info.plist
!! .DS_Store
!! ***/Resources/assets/***/
!! ***/Resources/assets/***/
!! ***/Resources/assets/***/
!! ***/Resources/assets/***/
!! ***/Resources/assets/***/
!! ***/Resources/assets/***/
!! ***/Resources/assets/***/
!! ***/Resources/assets/***.txt
!! ***/Resources/assets/***.xml
!! Gemfile.lock
!! fastlane/README.md
!! fastlane/build/
!! fastlane/report.xml
There was a problem hiding this comment.
Oh, I misinterpreted the git documentation. It states that if you only use
--ignored, without a value,traditionalis used - meaning, it's the same as using--ignored=traditional.
Maybe that differs from git version to git version? It would probably be a good idea to explicitly pass a default value of traditional to git status --porcelain --ignored='' if the argument is not set for the fastlane action.
There was a problem hiding this comment.
Looks good!
***:*** jenkins$ bundle exec fastlane run ensure_git_status_clean ignored:'none'
[✔] 🚀
[14:10:08]: -------------------------------------
[14:10:08]: --- Step: ensure_git_status_clean ---
[14:10:08]: -------------------------------------
[14:10:08]: $ git status --porcelain --ignored='no'
[14:10:08]: ▸ M ***/Info.plist
[14:10:08]: ▸ M Frameworks/***/Info.plist
[14:10:08]: ▸ M Frameworks/***/ios-arm64/***/Ast
[14:10:08]: ▸ M Frameworks/***/ios-arm64/***/Info.plist
[14:10:08]: ▸ M Gemfile
[14:10:08]: ▸ ?? Gemfile.lock
[!] Git repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first.
I also tested the other options (traditional and matching) and they work as expected.
2 things you might consider adding:
- Trimming the passed value for
ignored. If you pass i.e.ignored:'none 'the command will fail with an exception sincegit statuscan't handle that. - Checking for emptiness after trimming: If you pass i.e.
ignored:''orignored:' 'both will fail with an exception.
Both of these are just convenience and not a necessity for me to approve this pr. :)
There was a problem hiding this comment.
2 things you might consider adding
Oh, wow, you're amazing! Thanks for catching these too ❤️
There was a problem hiding this comment.
It looks like other actions don't strip trailing whitespace, so I'll do the same. Meaning, if you specify 'none ', it will treat it as an invalid value for the ignored parameter, and throw an error (which makes sense IMO).
Also, I think that you shouldn't and can't test this validation. Maybe because FastlaneCore::ConfigItem are already tested, and it doesn't make sense to test them again in the context of each individual action.
There was a problem hiding this comment.
You actually did, what I had in mind but was not bold enough to ask for because you did all the work so far. Creating a fixed set of options that can be used as arguments is what I would have done. I am a Swift developer though and it probably would have taken me days to figure this out. 🤣
Great work! Thanks.
There was a problem hiding this comment.
because you did all the work so far
It's easier if you already started to dive into stuff like this 😁
Creating a fixed set of options that can be used as arguments is what I would have done.
I'm wondering how come I didn't think of it in the first place 😅
I am a Swift developer though and it probably would have taken me days to figure this out.
Me too. I only rarely wrote Ruby, so I'm still getting the hang of it, which means that I sometimes fix stuff by trial and error 😂
Great work! Thanks.
And great work testing it and catching bugs! And thanks for finding this PR and linking to the issue. I actually did notice the difference between the code and the git man page, but I thought that the = is optional 😂
a14e3f8 to
92a812b
Compare
92a812b to
c8aa3c5
Compare
c8aa3c5 to
1c82399
Compare
|
Sorry, I was in vacation. I fixed it now 😁 |
Checklist
bundle exec rspecfrom the root directory to see all new and existing tests passbundle exec rubocop -ato ensure the code style is validci/circlecibuilds in the "All checks have passed" section of my PR (connect CircleCI to GitHub if not)Motivation and Context
Fixes #19818.
Description
See also: https://git-scm.com/docs/git-status#Documentation/git-status.txt---ignoredltmodegt
Testing Steps
Gemfile.bundle installbundle exec fastlane run ensure_git_status_clean