Age | Commit message (Collapse) | Author |
|
|
|
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.
|
|
|
|
|
|
These variants should make it easier to trace where in the code that a
particular error occurred, and include a context-descriptive error
message.
|
|
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.
|
|
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.
|
|
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);
}
}
|
|
|
|
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.
|
|
This gets rid of the default description string:
Unnamed repository; edit this file 'description' to name the repository.
|
|
|
|
Copy the repository description from GitHub into the clone repo.
|
|
|
|
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
|
|
Move hard-coded repository values to function arguments.
|
|
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
|