aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
AgeCommit message (Collapse)Author
2021-06-06Explicitly use tokio's multi-threaded runtimeTeddy Wing
Rather that relying on the Cargo features we've enabled to define this, create a multi-threaded runtime in code.
2021-06-06Make repo mirroring multi-threadedTeddy Wing
I think, at least. Took a lot of research and trial and error to get this to compile, working out how to set up the multi-threading for async code. The idea here is to be able to process each repo in potentially multiple threads and do that processing work in parallel.
2021-06-05run(): Move commentTeddy Wing
2021-06-05run(): Remove `unwrap`sTeddy Wing
2021-06-05main(): Remove commented test codeTeddy Wing
This is no longer relevant.
2021-06-05Add commented GitHub fetch call with command line username argumentTeddy Wing
Add command line argument value here in preparation for when we enable this code.
2021-06-05Replace hard-coded values with command line option valuesTeddy Wing
2021-06-05Use database path from command line argumentTeddy Wing
2021-06-05Move command line option parsing code to `run()`Teddy Wing
2021-06-05Add command line option parsingTeddy Wing
Define the options we want to take. Not using them yet.
2021-06-03main::update_mtime(): Use the packed-refs file if no default branch refTeddy Wing
A repository cloned with: $ git clone --mirror REPO doesn't have any ref files in `repo.git/refs/heads/*`. Instead, the refs are stored in `repo.git/packed-refs`. Update the pack file if the default branch ref file doesn't exist. CGit will look at the time on the 'packed-refs' file when that's the case.
2021-06-03main(): Use a smaller forked repository for testingTeddy Wing
The Angular.js repo was 51 MB, while DDHotKey is 95 K.
2021-05-30main::update_mtime(): Add function documentationTeddy Wing
2021-05-30Set repository mtime to GitHub `updated_at` timeTeddy Wing
CGit reads the repository modification time from the following locations, in order from top to bottom: 1. agefile 2. repo.git/refs/heads/{default_branch | "master"} 3. repo.git/packed-refs (https://git.zx2c4.com/cgit/tree/ui-repolist.c?id=bd6f5683f6cde4212364354b3139c1d521f40f39#n35) Update the `/refs/heads/{default_branch}` file mtime when cloning and updating the repo to match the GitHub `updated_at` time. This ensures that when mirroring old repositories, they don't appear at the top of the CGit repository index list when sorting by age.
2021-05-30github::fetch_repos(): Extract username to function argumentTeddy Wing
2021-05-30github::fetch_repos(): Fetch all repos from all pagesTeddy Wing
Also switch from `reqwest::blocking` to async because I was getting this error, probably because I call `fetch_repos()` in the async 'tokio' function `main()`: thread 'main' panicked at 'Cannot drop a runtime in a context where blocking is not allowed. This happens when a runtime is dropped from within an asynchronous context.', $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.6.1/src/runtime/blocking/shutdown.rs:51:21
2021-05-30main: Move current main code to `run()`Teddy Wing
We'll call this from `main()` when things are more ready.
2021-05-30main::mirror(): Remove handled commentTeddy Wing
This is all done now.
2021-05-30main::mirror(): Make the base cgitrc file optionalTeddy Wing
Allow user to not be required to specify a base cgitrc file for cloned repositories.
2021-05-30main::mirror(): Copy a base cgitrc file into the mirrored repositoryTeddy Wing
This lets us define common cgitrc configuration for all mirrored repos.
2021-05-30Only update repository description if the description changedTeddy Wing
Check the repository description that comes back from the GitHub API against our cached description in the database. Only write the new description if it changed so we can avoid writing to the file in that case.
2021-05-30database: Always try to create the database and tablesTeddy Wing
This is simpler, and means we don't have to check if the database file exists and only initialise if it doesn't. Here, we can just run the code and trust it will do the right thing in both cases.
2021-05-30main::update(): Add TODOTeddy 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-30main: Remove unused repo variable `r`Teddy Wing
Looks like I'm not going to be using this, since the functions in this match arm that take `database::Repo`s should take the one based on the `github::Repo` rather than the one fetched from the database.
2021-05-30main: Fetch from repositories that exist and have been updatedTeddy Wing
2021-05-30Clone forks to a `/fork/` pathTeddy Wing
Separate source and fork repositories into different paths.
2021-05-30Replace boxed errors with concrete error typesTeddy Wing
2021-05-30main::mirror: Take a `github::Repo` instead of repo attribute argumentsTeddy Wing
I wanted to move `clone_path` into `mirror()` so I could make a different clone path for forks.
2021-05-30Add repository description when mirroringTeddy Wing
Copy the repository description from GitHub into the clone repo.
2021-05-30main: Mirror new repositoriesTeddy Wing
If we haven't encountered a repository yet, mirror it to the filesystem. Change `From<github::Repo>` to `From<&github::Repo>` so we don't consume the repo and can use it later in the repo list loop.
2021-05-30main: Add notes for CGit mirroring stepsTeddy Wing
2021-05-30main: Add TODO for mirroring Git repositoryTeddy Wing
2021-05-30main: If repo was updated, save new `updated_at` valueTeddy Wing
If the repo was updated since we last cached it, update the `updated_at` column to the new value so we know that we fetched the latest.
2021-05-30Check if repo was updated based on `updated_at` timestampTeddy Wing
Find out if the latest copy is more recent than the cached value in our database.
2021-05-30main: If repo is not in database, insert itTeddy Wing
2021-05-30main: Add test `Repo` dataTeddy Wing
Will be using this to implement the main logic.
2021-05-30database: Add a way to get a single repoTeddy Wing
2021-05-29Create SQLite databaseTeddy Wing
Set up the database with a table for repositories so we can cache when they were last updated.
2021-05-29Start setting up database interfaceTeddy 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
2021-05-29Split GitHub API request into separate filesTeddy Wing
2021-05-29Parse GitHub API response to a structTeddy Wing
2021-05-29Move headers into HTTP client instead of requestTeddy Wing
2021-05-29Make a test request to the GitHub API to get user reposTeddy Wing
2021-05-29New Rust v1.50.0 projectTeddy Wing