-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Raise error if pinned hash from .configure
file is not found
#410
Open
mokagio
wants to merge
7
commits into
trunk
Choose a base branch
from
mokagio/fix-configure-nil-crash
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4d3a5ff
Fix typo in an informative comment
mokagio 16eb6c4
Raise error if pinned hash from `.configure` file is not found
mokagio 19231eb
Add note for why we don't check for a value being `nil`
mokagio 3fff855
Add changelog entry for #410
mokagio 9c3f507
Merge remote-tracking branch 'origin/trunk' into mokagio/fix-configur…
mokagio 952f393
Add integration tests for `configure_helper` `repo_branch_name`
mokagio 09d3863
Refactor `repo_branch_name` implementation to use Git API
mokagio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,11 +99,16 @@ def self.configure_file_is_behind_local | |
end | ||
|
||
def self.configure_file_commits_behind_repo | ||
# Get a sily number of revisions to ensure we don't miss any | ||
# Get a large number of revisions to ensure we don't miss any | ||
result = `cd #{repository_path} && git --no-pager log -10000 --pretty=format:"%H" && echo` | ||
hashes = result.each_line.map { |s| s.strip }.reverse | ||
|
||
index_of_configure_hash = hashes.find_index(configure_file_commit_hash) | ||
|
||
UI.user_error!("Could not find Git commit #{configure_file_commit_hash} from `.configure` file in local secrets repository. Please verify your local copy is up to date with the remote.") if index_of_configure_hash.nil? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
# No need to check for this to be `nil` because it comes by reading the | ||
# local `.mobile-secrets` repo itself. | ||
index_of_repo_commit_hash = hashes.find_index(repo_commit_hash) | ||
|
||
return 0 if index_of_configure_hash >= index_of_repo_commit_hash | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why the tool uses this kind of solution instead of using ad-hoc git commands like
git -c "#{repository_path}" rev-list --count #{configure_file_commit_hash}..HEAD
for example…There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's cool. I'll implement in the context of this PR because there's no rush to merge it as it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 In that case you might also want to take the occasion to look at the git Ruby gem (that I think we already use in other parts of the release-toolkit and is already one of our dependencies) to implement that call instead and to avoid the shell out 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the author (me) was a noob 😜
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mokagio FYI I am about to make a new release of the toolkit today to ship some new features I want to use in WPAndroid/WCAndroid.
Since you mentioned you'd implement the suggested change above in this PR rather than a separate one, I won't include this PR it in the upcoming release… except if you would like me to merge it as is (modulo CHANGELOG conflict resolution) now to include it after all, and plan for addressing the change in a future subsequent one? 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the ping. Here's another nice to have but not urgent PR that may take a while to get addressed... 🤔
I missed the boat on 6.1.0, #432, so I might as well keep this in the queue in the hope to get to it sooner rather than later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in 09d3863 with some help from Cursor to write the integration tests
Not impressed with the fact that I asked it to help me write tests to support refactoring and it suggested tests that stubbed out the method calls 😓