-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
f7a9870
to
5e60549
Compare
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"] } |
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.
What's the reason for using the git2
crate instead of the user's installed git binary?
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 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
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.
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 😉
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 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
8a66a45
to
1acc3c9
Compare
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.
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
.github/workflows/cd.yaml
Outdated
"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 |
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 we just install libgit2-dev directly instead of these custom packages? Might make it easier to maintain and more clear what's going on
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's possible, I did it, and I also moved it into a script to make it clearer!
7f71138
to
ea47281
Compare
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 |
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.
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"] |
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.
vendored-openssl = ["openssl/vendored"] |
Cargo.toml
Outdated
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"] } |
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.
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
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.
Well, the CI/CD is working fine now with this. I don't remember why I got into this (maybe the commit?)
.github/workflows/cd.yaml
Outdated
- name: Calculate openssl-vendored | ||
shell: bash | ||
id: is-openssl-vendored | ||
run: | |
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 would just get rid of all of the openssl stuff
src/commands/template.rs
Outdated
destination.display() | ||
)), | ||
Ok(_) => { | ||
init_repository(&pb, global.project.as_path(), None).map_err(|err| { |
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 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"); |
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.
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
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.
Ahh yep it's overriding user .gitconfig conf /: I've removed it!
d073bf2
to
4863d30
Compare
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.
Sorry! Last things
src/commands/new/use_case.rs
Outdated
) | ||
})?; | ||
.map_err(|e| format_permission_error("create use case", &dest, &e))?; | ||
init_repository(&pb, &dest, Some(competition.short_description))?; |
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.
this should probably just be a warning on fail
src/commands/template.rs
Outdated
destination.display() | ||
)), | ||
Ok(_) => { | ||
init_repository(&pb, &destination, None)?; |
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.
same here: just a warning
Cargo.toml
Outdated
openssl = { version = "0.10.68", features = ["vendored"], optional = true } | ||
openssl-probe = { version = "0.1.5", optional = true } |
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.
openssl = { version = "0.10.68", features = ["vendored"], optional = true } | |
openssl-probe = { version = "0.1.5", optional = true } |
are these still necessary?
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.
Oh, you're right, they're not. Thanks!
d951de2
to
6b1aaf1
Compare
6b1aaf1
to
6bee773
Compare
No description provided.