-
Notifications
You must be signed in to change notification settings - Fork 1
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 endpoint to run git fetch on outpack root #59
Conversation
@@ -156,6 +157,12 @@ async fn add_packet( | |||
.map(OutpackSuccess::from) | |||
} | |||
|
|||
async fn git_fetch(root: State<PathBuf>) -> Result<OutpackSuccess<()>, OutpackError> { |
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.
so this PR is a lot of work, but this is really nice
45bf126
to
8b10360
Compare
Since adding git2 crate we now have a dependency on OpenSSL which isn't immediately available in the manylinux containers. Fix this by * Using vendored version of OpenSSL * Install perl on RHEL targets
src/git.rs
Outdated
let repo = Repository::open(root)?; | ||
let mut remote = repo | ||
.find_remote("origin") | ||
.expect("Failed to find remote 'origin'"); |
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 guess these shouldn't happen in practice, but it would be good to return those errors rather than crash.
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, fixed that
git-utils/README.md
Outdated
@@ -0,0 +1,14 @@ | |||
# git-utils |
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.
Would it make more sense for this to be called test-utils
if the long term plan is to have more than just git stuff?
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.
Yes it would, I've updated that.
git-utils/src/lib.rs
Outdated
let mut file = File::create(repo_path.join(file_name)).unwrap(); | ||
file.write_all(b"File contents").unwrap(); |
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.
let mut file = File::create(repo_path.join(file_name)).unwrap(); | |
file.write_all(b"File contents").unwrap(); | |
std::fs::write(repo_path.join(file_name), b"File contents").unwrap() |
git-utils/src/lib.rs
Outdated
// local - 2 commits, initial, first commit | ||
// So that if we fetch on local then it should know about the second file | ||
pub fn initialise_git_repo(path: Option<&PathBuf>) -> TestGit { | ||
let tmp_dir = TempDir::new("repo").expect("Temp dir created").into_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.
into_path
means the directory never gets cleaned up, even after the program exists (unlike in R I think).
I would store the TempDir
object inside the TestGit
struct, then when that struct goes out of scope the folder is removed.
git-utils/src/lib.rs
Outdated
create_file(&remote_path, "new_file3"); | ||
git_add_all(&remote); | ||
git_commit(&remote, "Third commit"); | ||
git_checkout(&remote, &default_branch, false); |
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.
As an alternative to working with the worktree and the index and having to switch branches around, you could also use the lower level APIs that just modify the contents of .git
directly, eg. using https://docs.rs/git2/latest/git2/build/struct.TreeUpdateBuilder.html
Either options are fine, the lower level APIs are just a bit less stateful
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.
Ok had a quick look at that but a little confused about low level stuff. Tempted to stick with this since it is working but we can move to lower level if it proves brittle at all in the future?
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.
Yeah that’s fine.
For building the packit runner we want to let users have the ability to update git so that in the runner UI they can see their latest branches. This is to address the use case
This PR is a lot of testing and a little impl. I've put the git setup helpers into a separate crate as it seems like this is the only way we can use them in integration tests and unit tests without having it exported by the outpack crate.
Hoping we can use the test setup here for
Had quite a fight with the github actions which build the python bindings for the query parser. Turns out quite hard to have openssl available. I kind of wonder if we should instead break out the querying into a separate crate and just include that in the py03 build. The query parser doesn't need the git dependencies which are here and this adds a fair bit of complexity.