aboutsummaryrefslogtreecommitdiffstats
path: root/src/git.rs
AgeCommit message (Collapse)Author
2022-06-04Update copyright yearTeddy Wing
2022-06-03git.rs: Add more context to errorsTeddy Wing
Add full definitions for our new error variant ideas. Use a distinct variant and message in each error case in order to trace errors to the line of code where they occur.
2022-06-02git.rs: Ideas for error structure and contextTeddy Wing
2022-06-02git.rs: Add `Error::MirrorAddRemote` variantTeddy Wing
2022-06-02git.rs: Add ideas for new error variantsTeddy Wing
These variants should make it easier to trace where in the code that a particular error occurred, and include a context-descriptive error message.
2021-06-24main::update(): Change HEAD branch if default branch changedTeddy Wing
If the default branch on GitHub changed, change the local mirror's HEAD to match the new default. Need to store the default branch in the database now so we can find out whether it changed.
2021-06-24git::mirror(): Change HEAD to GitHub default branchTeddy Wing
The default branch after mirroring was typically 'master'. On GitHub, the default branch may not necessarily be 'master'. Change the default branch by changing the HEAD to GitHub's default branch so that the mirrored repository better matches GitHub. We'll also need to make a change to the update function in case the default branch changes after mirroring.
2021-06-23git::mirror(): Fix setting repository description on LinuxTeddy Wing
After a bunch of investigation, first with a small 'git2' project, then a 'libgit2-sys' project, then a 'libgit2' C project, I finally discovered why setting the description worked on Mac OS but not on Linux. Turning on the `GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE` repository init flag caused the default description to be used instead of the custom description passed in the init. Turn off the flag to allow us to set the description on Linux. Here is the source of the test builds I made: git2 test: use git2; fn main() { let path = "/tmp/test-repo"; let description = "the description"; let repo = git2::Repository::init_opts( path, &git2::RepositoryInitOptions::new() .bare(true) .external_template(false) .description(description), ).unwrap(); } libgit2-sys test: use libgit2_sys; use std::ffi::CString; use std::ptr; fn main() { let _ = unsafe { libgit2_sys::git_libgit2_init() }; let mut repo = ptr::null_mut(); let path = CString::new("/tmp/test-repo").unwrap(); let description = CString::new("Test").unwrap(); let mut opts = libgit2_sys::git_repository_init_options { version: libgit2_sys::GIT_REPOSITORY_INIT_OPTIONS_VERSION, flags: libgit2_sys::GIT_REPOSITORY_INIT_MKDIR as u32 | libgit2_sys::GIT_REPOSITORY_INIT_MKPATH as u32 | libgit2_sys::GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE as u32, mode: 0, workdir_path: ptr::null(), description: description.as_ptr(), template_path: ptr::null(), initial_head: ptr::null(), origin_url: ptr::null(), }; let error = unsafe { libgit2_sys::git_repository_init_ext( &mut repo, path.as_ptr(), &mut opts, ) }; dbg!(&error); } libgit2 test: #include <stdio.h> #include "git2.h" int main() { int error; const git_error *lg2err; error = git_libgit2_init(); if (error <= 0) { printf("git_libgit2_init error: %d\n", error); } git_repository *repo = NULL; git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT; /* Customize options */ opts.flags |= GIT_REPOSITORY_INIT_MKPATH; /* mkdir as needed to create repo */ opts.flags |= GIT_REPOSITORY_INIT_MKDIR; /* opts.flags |= GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE; */ opts.description = "Custom test description"; error = git_repository_init_ext(&repo, "/tmp/test-repo", &opts); printf("git_repository_init_ext error: %d\n", error); lg2err = git_error_last(); if (lg2err != NULL) { printf("%s\n", lg2err->message); } }
2021-06-07Add license (GNU GPLv3+)Teddy Wing
2021-05-30main::update(): Update repository description on fetch updateTeddy Wing
If the repository was updated, write the description into the `description` file. Add a `github::Repo.description()` method to get an empty string if the description is `None`. This facilitates writing to the `description` file.
2021-05-30git::mirror(): Write empty description if `description` is `None`Teddy Wing
This gets rid of the default description string: Unnamed repository; edit this file 'description' to name the repository.
2021-05-30Replace boxed errors with concrete error typesTeddy Wing
2021-05-30Add repository description when mirroringTeddy Wing
Copy the repository description from GitHub into the clone repo.
2021-05-29src/git.rs: Add function documentationTeddy Wing
2021-05-29Add function to update a Git repositoryTeddy Wing
Should work like: $ git remote update From what I can tell from: https://github.com/git/git/blob/a0dda6023ed82b927fa205c474654699a5b07a82/builtin/remote.c#L1452-L1490 this translates to something like: $ git fetch --prune --multiple default --all
2021-05-29git::mirror(): Extract argumentsTeddy Wing
Move hard-coded repository values to function arguments.
2021-05-29Work out how to mirror a Git repositoryTeddy Wing
Based on the guide here: https://libgit2.org/docs/guides/101-samples/#repositories_clone_mirror References: https://github.com/libgit2/libgit2sharp/issues/577 https://github.com/libgit2/libgit2.github.io/pull/31