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

feat: init a Git repo for default use_case template #97

Merged
merged 8 commits into from
Dec 7, 2024

Conversation

Angel-Dijoux
Copy link
Contributor

No description provided.

Cargo.toml Outdated
@@ -92,6 +93,9 @@ tracing-subscriber = { version = "0.3", features = ["json", "env-filter"] }
url = { version = "2.5", features = ["serde"] }
uuid = "1.7"
which = "6.0"
openssl = { version = "0.10.68", features = ["vendored"], optional = true }
openssl-probe = { version = "0.1.5", optional = true }
git2 = { version = "0.19.0" , features = ["vendored-openssl"] }
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason for using the git2 crate instead of the user's installed git binary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't want to rely on the user's environment to be honest, also on our side it is easier to manipulate the library compared to system commands

Copy link
Contributor

Choose a reason for hiding this comment

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

Relying on the user's environment in this case might be beneficial because what's the point of initializing a git repo if they do not have git installed?

easier to manipulate would also be an overstretch in my humble opinion.

I just wanted to advocate for this solution because it might simplify our CI too. Everything looks good apart from that 😉

Copy link
Contributor

Choose a reason for hiding this comment

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

I also thought about relying on the user's git, but I looked at how cargo handles it, and they do use git2 so I think this solution is fine. In any case it's not a huge deal for someone to have an unnecessary .git directory

@Angel-Dijoux Angel-Dijoux force-pushed the angel/init_git_use_case branch 3 times, most recently from 8a66a45 to 1acc3c9 Compare November 15, 2024 00:56
@Angel-Dijoux Angel-Dijoux self-assigned this Nov 15, 2024
Copy link
Contributor

@jpopesculian jpopesculian left a comment

Choose a reason for hiding this comment

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

Had a quick peek, and I would say we should stick to only creating the empty git directly and not be doing any commits, I wouldn't want to mess with anyone's commit history and we also can't be certain which files to add and that can be really frustrating to reverse

"aarch64" | "armv7" | "s390x" | "ppc64le")
# NOTE: pypa/manylinux docker images are Debian based
sudo apt-get update
sudo apt-get install -y pkg-config libssl-dev
Copy link
Contributor

Choose a reason for hiding this comment

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

can we just install libgit2-dev directly instead of these custom packages? Might make it easier to maintain and more clear what's going on

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's possible, I did it, and I also moved it into a script to make it clearer!

@Angel-Dijoux Angel-Dijoux force-pushed the angel/init_git_use_case branch from 7f71138 to ea47281 Compare November 20, 2024 18:00
@Angel-Dijoux
Copy link
Contributor Author

Had a quick peek, and I would say we should stick to only creating the empty git directly and not be doing any commits, I wouldn't want to mess with anyone's commit history and we also can't be certain which files to add and that can be really frustrating to reverse

Oh yes! You're right. I thought it was a good idea, but from this point of view, not really I agree, it's been removed thanks

Copy link
Contributor

@jpopesculian jpopesculian left a comment

Choose a reason for hiding this comment

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

Looking good! Let me know if it works to get rid of the default features for git2 and avoid the hassle with openssl

Cargo.toml Outdated
@@ -19,6 +19,7 @@ name = "aqora"
[features]
default = []
extension-module = ["pyo3/extension-module", "pyo3/abi3-py39", "pyo3/abi3"]
vendored-openssl = ["openssl/vendored"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
vendored-openssl = ["openssl/vendored"]

Cargo.toml Outdated
Comment on lines 96 to 98
openssl = { version = "0.10.68", features = ["vendored"], optional = true }
openssl-probe = { version = "0.1.5", optional = true }
git2 = { version = "0.19.0" , features = ["vendored-openssl"] }
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
openssl = { version = "0.10.68", features = ["vendored"], optional = true }
openssl-probe = { version = "0.1.5", optional = true }
git2 = { version = "0.19.0" , features = ["vendored-openssl"] }
git2 = { version = "0.19.0", default-features = false }

We don't need to use ssh or https because we don't ever interact with remote servers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, the CI/CD is working fine now with this. I don't remember why I got into this (maybe the commit?)

- name: Calculate openssl-vendored
shell: bash
id: is-openssl-vendored
run: |
Copy link
Contributor

Choose a reason for hiding this comment

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

I would just get rid of all of the openssl stuff

destination.display()
)),
Ok(_) => {
init_repository(&pb, global.project.as_path(), None).map_err(|err| {
Copy link
Contributor

Choose a reason for hiding this comment

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

why not stick format_permission_error in crate::error and reuse it here? also init_repository could also just return create::Result<()> to save yourself some unnecessary error formatting

src/git.rs Outdated
.as_str(),
)
.no_reinit(true)
.initial_head("main");
Copy link
Contributor

Choose a reason for hiding this comment

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

you'd have to check if this gets automatically putlled from the users .gitconfig. If it does, I wouldn't want to mess with their local configuration

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh yep it's overriding user .gitconfig conf /: I've removed it!

@Angel-Dijoux Angel-Dijoux force-pushed the angel/init_git_use_case branch 2 times, most recently from d073bf2 to 4863d30 Compare November 25, 2024 20:16
Copy link
Contributor

@jpopesculian jpopesculian left a comment

Choose a reason for hiding this comment

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

Sorry! Last things

)
})?;
.map_err(|e| format_permission_error("create use case", &dest, &e))?;
init_repository(&pb, &dest, Some(competition.short_description))?;
Copy link
Contributor

Choose a reason for hiding this comment

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

this should probably just be a warning on fail

destination.display()
)),
Ok(_) => {
init_repository(&pb, &destination, None)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

same here: just a warning

Cargo.toml Outdated
Comment on lines 95 to 96
openssl = { version = "0.10.68", features = ["vendored"], optional = true }
openssl-probe = { version = "0.1.5", optional = true }
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
openssl = { version = "0.10.68", features = ["vendored"], optional = true }
openssl-probe = { version = "0.1.5", optional = true }

are these still necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, you're right, they're not. Thanks!

@jpopesculian jpopesculian force-pushed the angel/init_git_use_case branch from 6b1aaf1 to 6bee773 Compare December 7, 2024 10:58
@jpopesculian jpopesculian merged commit 0d7408d into main Dec 7, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants