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
Alias collision #10859
base: master
Are you sure you want to change the base?
Alias collision #10859
Conversation
I think we need to make this a zsh check to account for dynamic alias definitions and function conflicts (i.e. "aliases" that are defined as functions, like #10851). A way to do this could be to run zsh, then parse the output of The problem of side-effects and running extra code (things not related to aliases and functions) would need to be considered as well. I'll think carefully about this last part. Good start though, love that it contains tests! |
Is there an easy way to source all plugins? Then I would give it a try to see how the runtime will behave. The current implementation already found a few duplicates. How should we proceed here? I could create a separate issue for every plugin to kickof a discussion for resolving the name conflict. |
@mcornella How should we proceed here? I could create a separate issue for every plugin to kickoff a discussion for resolving the name conflict. We anyhow have to resolve the name conflicts before we can use the CI check in a reasonable way. And how to proceed with the implementation. Since this already found some conflicts and might prevent future ones, we could already integrate it and improve with a follow up PR that parses the output of |
@mcornella How should we proceed here? Is this still relevant for you? |
I'd push for a zsh check, so we can check also functions. Another problem might be that some aliases are defined only if some binary is present in |
@carlosala Agreed. My suggestion on how to proceed would be to go with this check for now and fix everything that was catched so far. Once this is done, we can extend the check for functions and everything else that comes to our mind. I am also starting list here with alias collisions we need to solve and my suggestions/ideas to resolve them:
|
38d6ba2
to
c9e5579
Compare
ed78d86
to
6d5a1f0
Compare
I would vote for "fix them as part of this PR" 😉 |
@carlosala What is you opinion on how to proceed with the existing alias collisions? |
Hey Markus, the technical work so far is spotless but I'm not sure how we proceed with the aspect of solving collisions. Perhaps we can proceed with a CI approach that is "this PR does not introduce new collisions", kinda like how an iterative approach is done with unit testing. For this, the output of the tool would need to be refined and the job changed so it makes the comparison between master and the PR. I will work on refining the CI part and then we can begin a new issue discussing how to approach current alias collisions. Thank you for your work! |
I think we can move this forward! I'd go for the "this PR does not add new collisions" thing, and it'd be great to add an automated check as well for collisions with other cli binaries, leveraging something like https://command-not-found.com |
Since this would be a CI-only check, I'm OK going for python. Previously I mentioned something like turning this PR into a shell script, but python is the way to go IMO. 👍🏻 |
Sounds good to me. I would leave the binary tool collision for a follow up PR then. At some point, we could also consider making the part of a tool such as https://pre-commit.com. But I guess you don't want any user/developer to depend on Python. |
Yep, it's probably better to have that only on CI 👍🏻 |
6d5a1f0
to
d562ccd
Compare
@carlosala I slightly refactored this PR to use pytest over unittest, which is just nicer to use. With #10859 (comment), I added a filter that lists all know collisions. Execpt for those, the check will fail for new collisions. In the future we can work on reducing collisions and extend with further checks. |
8ccc175
to
5062134
Compare
I removed the known collision resolved in #12192 |
@carlosala quick reminder to move on with this |
If I understand the motivation for you approach correctly, you want to avoid storing the json file in VCS, right? On the other hand, having the reference from master in VCS, it is easier to track the status about how many collision you have right now. Regardless of which way we go for, do you think this could become a follow up PR? This PR, as is provides already value and would prevent new collisions from being introduced. |
Yep, exactly. I'd say it's better not to have it in the repo. |
5062134
to
c9282c5
Compare
@carlosala I updated the GH action. Now we create the baseline file on the source branch. I a second step, we compare the target branch collisions with this baseline. |
Could you move all this code to |
I'll verify the python code during this week, thanks for the hard work! |
Should I moved it into the same folder and merge the requirements.txt or into a seperate one? |
I'd do different ones actually |
Moved it to |
Some things I spotted along the way:
[
{
"alias": "<duplicated>"
"locations": ["<file1>", "<file2>", "...", "<fileN>"]
}
] Main issue with it: if we have to equal aliases in the same file, weird corner cases might appear.
|
I'll keep reviewing it during the next days, but really great job! |
Standards checklist:
Changes:
Relates #10857
This is a first draft checking for alias collisions. I used Python to implement this feature to provide a solid set of tests and added a job to the GH actions
Other comments:
Since this is a first draft there a some open points to discuss:
tools
folder. Is this locations fine or should we move it somewhere else?