-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
tap_auditor: ensure lists of packages are in sorted order #19972
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
base: master
Are you sure you want to change the base?
Conversation
a1c1a11
to
eead40c
Compare
list_without_versions = if list_file == ".github/autobump.txt" | ||
list | ||
else | ||
# Allow versioned packages not to follow the strict order |
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.
Why?
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 sometimes we want to arrange versioned in different order. Instead of ["package@1.10", "package@1.11", "package@1.9"]
I'd prefer ["package@1.9", "package@1.10", "package@1.11"]
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.
It would be nice to enforce that ordering.
list.map { |s| s.split("@", 2).first } | ||
end | ||
|
||
sorted = list_without_versions.each_cons(2).all? do |a, b| |
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.
Why the 2
?
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.
There's no built-in method to check if an array is sorted so I had to implement it on my own, see similar question on StackOverflow
https://stackoverflow.com/questions/8015775/check-to-see-if-an-array-is-already-sorted
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.
Generally comparing the array
and array.sort
is an easy way to verify this.
a <= b | ||
end | ||
|
||
sorted = true if list_file == "formula_renames" # Skip sort check for renames |
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.
Why?
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.
fromula_renames
audit works with values of the keys, not the keys themselves.
In JSON like
{
"amtk": "libgedit-amtk",
"annie": "lux",
"ark": "velero",
"arm": "nyx",
"asciigen": "glyph"
}
it checks if array ["libgedit-amtk", "lux", "velero", "nyx", "glyph"]
is sorted
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.
do we check both keys and values are sorted elsewhere?
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.
The check is performed only on values, keys are not checked at all
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.
Feels like it'd be desirable to sort both keys and values.
Signed-off-by: botantony <antonsm21@gmail.com>
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?It would be nice to check if lists of formulae/casks in files (f.e.
autobump.txt
orformula_renames
) are in sorted order