-
Notifications
You must be signed in to change notification settings - Fork 823
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
Add ability to set an order of groups #613
Add ability to set an order of groups #613
Conversation
Is this only at the top level? How about being able to do it on sub-levels as well? Maybe that is covered by your second example, I'm not sure. |
No, it's work on any level and you are right, it's covered by the second example. I'll update the 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.
Thanks for the PR @Beniamiiin. How important is it to your team to have this sorting? Both for the top level and for sub groups?
Docs/ProjectSpec.md
Outdated
@@ -114,6 +114,7 @@ Note that target names can also be changed by adding a `name` property to a targ | |||
- `none` - sorted alphabetically with all the other files | |||
- `top` - at the top, before files | |||
- `bottom` (default) - at the bottom, after other files | |||
- [ ] **groupsOrder**: **[[GroupOrder]](#groupOrder)** - An order of groups. |
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 in love with the name groupsOrder
, but I also can't think of something better right now.
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 only you, I don't like it too, but I couldn't find more lovely name :( I'll try to think about it again.
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.
How about groupOrdering
?
} else { | ||
if child1.nameOrPath != child2.nameOrPath { | ||
return child1.nameOrPath.localizedStandardCompare(child2.nameOrPath) == .orderedAscending | ||
if let groupOrder = project.options.groupsOrder.first(where: { group.nameOrPath == $0.pattern || group.nameOrPath.isMatch(to: $0.pattern) }) { |
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.
nameOrPath
evaluates to name ?? path ?? ""
. That means groups who have a different path than just the name won't be supported.
In either case doing something like Group1/Group2/*
won't work as the name is just the end and the path is a relative path.
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.
Okay, so should I to use just name
?
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.
@yonaskolb I need your help. I don't understand what is the correct way to do it.
I'll say for us that the top level is pretty important. We've gone the route of adding |
For us, it's important because currently, we use my fork with the implementation of this feature. |
@Beniamiiin @yonaskolb What is needed to move this forward? We personally would love this feature landed. |
@brentleyjones firstly I need some help from @yonaskolb to fix all review issues and secondly @yonaskolb should review the PR again. |
@yonaskolb are we gonna do something with this PR? |
@yonaskolb are we gonna do something with this PR? |
I'm still a big fan of this change as well. @yonaskolb, since you had some PR comments I'll leave it to you to re-review. Thanks! |
@yonaskolb I'm so sorry can you give us some information about this PR? |
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.
Can you add some test fixtures? Showing how it doesn't affect ordering when the property isn't declared, and some that covers all of the functionality listed.
I'll give this a spin locally as well. If nothing comes up there, after the changes we should be good to go.
Docs/ProjectSpec.md
Outdated
@@ -114,6 +114,7 @@ Note that target names can also be changed by adding a `name` property to a targ | |||
- `none` - sorted alphabetically with all the other files | |||
- `top` - at the top, before files | |||
- `bottom` (default) - at the bottom, after other files | |||
- [ ] **groupsOrder**: **[[GroupOrder]](#groupOrder)** - An order of groups. |
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.
How about groupOrdering
?
It runs nicely with our project, so just looking for the requested changed and we should be good to go. |
for groupName in order { | ||
guard let group = groups.first(where: { $0.nameOrPath == groupName }) else { | ||
continue | ||
} | ||
|
||
filteredGroups.append(group) | ||
groups.removeAll { $0 == group } | ||
} |
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.
I think this will cause performance issues in large projects that use a regex pattern, as there are a lot of nested loops here, but I guess it's up to the project author to take on that cost
@Beniamiiin: after @yonaskolb's feedback is addressed and this is rebased on master, we can merge it. Thanks! |
@brentleyjones I'll do it at this weekend. |
# Conflicts: # CHANGELOG.md
@yonaskolb can you review it again please |
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.
Since this feature is gated behind people using it, and it works in it's current state, I say we merge this and address any issues in followup PRs.
@Beniamiiin Found this feature today. Very useful, thank you! |
Hi @yonaskolb.
I implemented the option called
groupOrder
. It's for setting an order of groups. Currently, we can just set thegroupSortPosition
, but sometimes we wanna set directly order of groups.Some examples
I have a project with a structure:
Without
groupOrder
option it will be sorted alphabetically, to set the order as above we can use the new option in this way:Screen
.I have a group with a structure:
With out
groupOrder
option, it will be sorted alphabetically, to set the order as above we can use the new option in this way: