Skip to content
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 support for aliases to ov #4409

Merged
merged 1 commit into from
May 31, 2024
Merged

Conversation

sarayourfriend
Copy link
Collaborator

@sarayourfriend sarayourfriend commented May 30, 2024

Fixes

Fixes #4407 by @sarayourfriend

cc @AetherUnbound and @dhruvkb who are probably the most interested with this.

Description

An alternative to #4408 using a Python-based approach.

This approach has all the features of the bash approach in #4408, but none of the disadvantages. It shares the same overall problems like the aliases only being available in the entrypoint. They aren't available inside just recipes themselves, for example. I think that's fine though!

Testing Instructions

Try ov j, ov nuxt, and ov welcome. See if it works and makes sense!

Checklist

  • My pull request has a descriptive title (not a vague title likeUpdate index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.
  • [N/A] I ran the DAG documentation generator (just catalog/generate-docs for catalog
    PRs) or the media properties generator (just catalog/generate-docs media-props
    for the catalog or just api/generate-docs for the API) where applicable.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@sarayourfriend sarayourfriend added 🟩 priority: low Low priority and doesn't need to be rushed 🌟 goal: addition Addition of new feature 🤖 aspect: dx Concerns developers' experience with the codebase 🧱 stack: mgmt Related to repo management and automations labels May 30, 2024
@sarayourfriend sarayourfriend requested a review from a team as a code owner May 30, 2024 06:36
Copy link
Collaborator

@AetherUnbound AetherUnbound left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is excellent, and works great locally! I also needed to run ov build && ov init first, but after that ov welcome ran fine. Interesting and cool workaround!

ov
@@ -57,7 +57,7 @@ fi
case "$_cmd" in
init)
"$_self" build
"$_self" just install-hooks
"$_self" 'just install-hooks && just init-ov-aliases'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the help text up above will also need to reference this change!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, yes it will, thanks!

@sarayourfriend
Copy link
Collaborator Author

sarayourfriend commented May 30, 2024

I also needed to run ov build && ov init first

Ah, of course.

Hopefully the entrypoint doesn't need to change that often, but if we find it does for some reason, we can change it to a stub script that just passes through to a mounted script that doesn't need to be copied into the container. Something like

# entrypoint.sh

"$OPENVERSE_PROJECT"/docker/dev_env/configure_environment.sh "$@"
python "$OPENVERSE_PROJECT"/docker/dev_env/exec.py "$@"

Maybe?

Copy link
Member

@dhruvkb dhruvkb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I would have preferred a more standard way to define aliases than using a Python script, but this works well so it's okay with me.


SHARED_ALIASES = {
"j": ["just"],
"nuxt": ["j", "p", "frontend", "dev"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like preferential treatment for the frontend 😄.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was just the first useful one I could think of that clearly illustrated multi-term expansion 😅

@sarayourfriend sarayourfriend merged commit c4cb14e into main May 31, 2024
70 checks passed
@sarayourfriend sarayourfriend deleted the add/alias-support-python branch May 31, 2024 06:29
@krysal
Copy link
Member

krysal commented May 31, 2024

This is pretty cool! I also had to run ./ov init, worked perfectly after that ✨

However, I cannot commit after this without skipping pre-commit validations 😅

.git/hooks/pre-commit: line 5: ov: command not found

@dhruvkb
Copy link
Member

dhruvkb commented May 31, 2024

@krysal you have to link the ov script to a directory that's on your $PATH. On a Mac, /usr/local/bin is typically on the $PATH so this should work.

sudo ln -s <path to repo>/ov /usr/local/bin/ov
image

@sarayourfriend
Copy link
Collaborator Author

Oh, that's no good! The hooks shouldn't rely on ov being in the path, that's definitely a bug. They should reference the script directly, I guess by relative path? I'm not sure what the CWD of a git hook is but I'm sure it's easy to find out. Issue here to fix that :#4422

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 aspect: dx Concerns developers' experience with the codebase 🌟 goal: addition Addition of new feature 🟩 priority: low Low priority and doesn't need to be rushed 🧱 stack: mgmt Related to repo management and automations
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Add support for aliases in ov
4 participants