Compare commits
3 commits
cde9531150
...
5cee80622f
Author | SHA1 | Date | |
---|---|---|---|
5cee80622f | |||
942a71efd4 | |||
3642b2cdd1 |
17 changed files with 208 additions and 80 deletions
|
@ -2,8 +2,16 @@
|
||||||
|
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [0.6.1] - 2024-05-25
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
- New commit_log matches original from API request ([3642b2c](https://git.kemitix.net/kemitix/git-next/commit/3642b2cdd11de2bf49c1214c9938a86517d6a7fd))
|
||||||
|
|
||||||
## [0.6.0] - 2024-05-25
|
## [0.6.0] - 2024-05-25
|
||||||
|
|
||||||
|
[8616225](https://git.kemitix.net/kemitix/git-next/commit/8616225a28d94964401c6de6442c7408848f6c1f)...[6cab8bb](https://git.kemitix.net/kemitix/git-next/commit/6cab8bb2baf7ae8300f9496c1e843531839e30e5)
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
- Config file watcher will respond to touch ([ebbb655](https://git.kemitix.net/kemitix/git-next/commit/ebbb655bfca3561059e068606a32dcb17d490f5e))
|
- Config file watcher will respond to touch ([ebbb655](https://git.kemitix.net/kemitix/git-next/commit/ebbb655bfca3561059e068606a32dcb17d490f5e))
|
||||||
|
@ -11,6 +19,7 @@ All notable changes to this project will be documented in this file.
|
||||||
### Miscellaneous Tasks
|
### Miscellaneous Tasks
|
||||||
|
|
||||||
- Don't directly open coverage report ([c92e41e](https://git.kemitix.net/kemitix/git-next/commit/c92e41ee564f36470511b2d093c1e00ae66078d4))
|
- Don't directly open coverage report ([c92e41e](https://git.kemitix.net/kemitix/git-next/commit/c92e41ee564f36470511b2d093c1e00ae66078d4))
|
||||||
|
- Release 0.6.0 ([6cab8bb](https://git.kemitix.net/kemitix/git-next/commit/6cab8bb2baf7ae8300f9496c1e843531839e30e5))
|
||||||
|
|
||||||
### Refactor
|
### Refactor
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,12 @@ members = [
|
||||||
"crates/git",
|
"crates/git",
|
||||||
"crates/forge",
|
"crates/forge",
|
||||||
"crates/forge-forgejo",
|
"crates/forge-forgejo",
|
||||||
|
"crates/forge-github",
|
||||||
"crates/repo-actor",
|
"crates/repo-actor",
|
||||||
]
|
]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.6.0"
|
version = "0.6.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[workspace.lints.clippy]
|
[workspace.lints.clippy]
|
||||||
|
@ -26,6 +27,7 @@ git-next-config = { path = "crates/config" }
|
||||||
git-next-git = { path = "crates/git" }
|
git-next-git = { path = "crates/git" }
|
||||||
git-next-forge = { path = "crates/forge" }
|
git-next-forge = { path = "crates/forge" }
|
||||||
git-next-forge-forgejo = { path = "crates/forge-forgejo" }
|
git-next-forge-forgejo = { path = "crates/forge-forgejo" }
|
||||||
|
git-next-forge-github = { path = "crates/forge-github" }
|
||||||
git-next-repo-actor = { path = "crates/repo-actor" }
|
git-next-repo-actor = { path = "crates/repo-actor" }
|
||||||
|
|
||||||
# CLI parsing
|
# CLI parsing
|
||||||
|
|
|
@ -4,7 +4,7 @@ version = { workspace = true }
|
||||||
edition = { workspace = true }
|
edition = { workspace = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["forgejo"]
|
default = ["forgejo", "github"]
|
||||||
forgejo = []
|
forgejo = []
|
||||||
github = []
|
github = []
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ pub async fn validate_positions(
|
||||||
) -> git::validation::Result {
|
) -> git::validation::Result {
|
||||||
let repo_details = &forge.repo_details;
|
let repo_details = &forge.repo_details;
|
||||||
// Collect Commit Histories for `main`, `next` and `dev` branches
|
// Collect Commit Histories for `main`, `next` and `dev` branches
|
||||||
|
repository.fetch()?;
|
||||||
let commit_histories =
|
let commit_histories =
|
||||||
get_commit_histories(repository, repo_details, &repo_config, &forge.net).await;
|
get_commit_histories(repository, repo_details, &repo_config, &forge.net).await;
|
||||||
let commit_histories = match commit_histories {
|
let commit_histories = match commit_histories {
|
||||||
|
@ -23,7 +24,6 @@ pub async fn validate_positions(
|
||||||
return Err(git::validation::Error::Network(Box::new(err)));
|
return Err(git::validation::Error::Network(Box::new(err)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Validations
|
// Validations
|
||||||
let Some(main) = commit_histories.main.first().cloned() else {
|
let Some(main) = commit_histories.main.first().cloned() else {
|
||||||
warn!(
|
warn!(
|
||||||
|
@ -60,7 +60,6 @@ pub async fn validate_positions(
|
||||||
let next_is_ancestor_of_dev = commit_histories.dev.iter().any(|dev| dev == &next);
|
let next_is_ancestor_of_dev = commit_histories.dev.iter().any(|dev| dev == &next);
|
||||||
if !next_is_ancestor_of_dev {
|
if !next_is_ancestor_of_dev {
|
||||||
info!("Next is not an ancestor of dev - resetting next to main");
|
info!("Next is not an ancestor of dev - resetting next to main");
|
||||||
|
|
||||||
if let Err(err) = forge.branch_reset(
|
if let Err(err) = forge.branch_reset(
|
||||||
repository,
|
repository,
|
||||||
repo_config.branches().next(),
|
repo_config.branches().next(),
|
||||||
|
@ -77,11 +76,12 @@ pub async fn validate_positions(
|
||||||
repo_config.branches().next(),
|
repo_config.branches().next(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let next_commits = commit_histories
|
let next_commits = commit_histories
|
||||||
.next
|
.next
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.take(2)
|
.take(2) // next should never be more than one commit ahead of main, so this should be
|
||||||
|
// either be next and main on two adjacent commits, or next and main on the same commit,
|
||||||
|
// plus the parent of main.
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
if !next_commits.contains(&main) {
|
if !next_commits.contains(&main) {
|
||||||
warn!(
|
warn!(
|
||||||
|
@ -128,7 +128,6 @@ pub async fn validate_positions(
|
||||||
repo_config.branches().next(),
|
repo_config.branches().next(),
|
||||||
)); // dev is not based on next
|
)); // dev is not based on next
|
||||||
}
|
}
|
||||||
|
|
||||||
let Some(dev) = commit_histories.dev.first().cloned() else {
|
let Some(dev) = commit_histories.dev.first().cloned() else {
|
||||||
warn!(
|
warn!(
|
||||||
"No commits on dev branch '{}'",
|
"No commits on dev branch '{}'",
|
||||||
|
@ -138,7 +137,6 @@ pub async fn validate_positions(
|
||||||
repo_config.branches().dev(),
|
repo_config.branches().dev(),
|
||||||
));
|
));
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(git::validation::Positions {
|
Ok(git::validation::Positions {
|
||||||
main,
|
main,
|
||||||
next,
|
next,
|
||||||
|
@ -170,12 +168,11 @@ async fn get_commit_histories(
|
||||||
net,
|
net,
|
||||||
)
|
)
|
||||||
.await)?;
|
.await)?;
|
||||||
let next_head = next[0].clone();
|
|
||||||
let dev = (get_commit_history(
|
let dev = (get_commit_history(
|
||||||
repository,
|
repository,
|
||||||
repo_details,
|
repo_details,
|
||||||
&repo_config.branches().dev(),
|
&repo_config.branches().dev(),
|
||||||
&[next_head, main_head],
|
&[main_head],
|
||||||
net,
|
net,
|
||||||
)
|
)
|
||||||
.await)?;
|
.await)?;
|
||||||
|
@ -189,6 +186,7 @@ async fn get_commit_histories(
|
||||||
Ok(histories)
|
Ok(histories)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all, fields(%branch_name, ?find_commits))]
|
||||||
async fn get_commit_history(
|
async fn get_commit_history(
|
||||||
repository: &git::repository::OpenRepository,
|
repository: &git::repository::OpenRepository,
|
||||||
repo_details: &git::RepoDetails,
|
repo_details: &git::RepoDetails,
|
||||||
|
@ -204,7 +202,7 @@ async fn get_commit_history(
|
||||||
info!("new version matches");
|
info!("new version matches");
|
||||||
Ok(updated)
|
Ok(updated)
|
||||||
} else {
|
} else {
|
||||||
error!(?updated, ?original, "new version doesn't match original");
|
error!("new version doesn't match original");
|
||||||
Ok(original)
|
Ok(original)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,8 +267,13 @@ async fn original_get_commit_history(
|
||||||
|| find_commits
|
|| find_commits
|
||||||
.iter()
|
.iter()
|
||||||
.any(|find_commit| commits.iter().any(|commit| commit == find_commit));
|
.any(|find_commit| commits.iter().any(|commit| commit == find_commit));
|
||||||
let at_end = commits.len() < limit;
|
let at_end = commits.len() < limit; // i.e. less than the number of commits requested
|
||||||
all_commits.extend(commits);
|
for commit in commits {
|
||||||
|
all_commits.push(commit.clone());
|
||||||
|
if find_commits.contains(&commit) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
if found || at_end {
|
if found || at_end {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
59
crates/forge-github/Cargo.toml
Normal file
59
crates/forge-github/Cargo.toml
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
[package]
|
||||||
|
name = "git-next-forge-github"
|
||||||
|
version = { workspace = true }
|
||||||
|
edition = { workspace = true }
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
git-next-config = { workspace = true }
|
||||||
|
git-next-git = { workspace = true }
|
||||||
|
|
||||||
|
# logging
|
||||||
|
console-subscriber = { workspace = true }
|
||||||
|
tracing = { workspace = true }
|
||||||
|
tracing-subscriber = { workspace = true }
|
||||||
|
|
||||||
|
# base64 decoding
|
||||||
|
base64 = { workspace = true }
|
||||||
|
|
||||||
|
# git
|
||||||
|
async-trait = { workspace = true }
|
||||||
|
|
||||||
|
# fs/network
|
||||||
|
kxio = { workspace = true }
|
||||||
|
|
||||||
|
# TOML parsing
|
||||||
|
serde = { workspace = true }
|
||||||
|
serde_json = { workspace = true }
|
||||||
|
toml = { workspace = true }
|
||||||
|
|
||||||
|
# Secrets and Password
|
||||||
|
secrecy = { workspace = true }
|
||||||
|
|
||||||
|
# Conventional Commit check
|
||||||
|
git-conventional = { workspace = true }
|
||||||
|
|
||||||
|
# Webhooks
|
||||||
|
bytes = { workspace = true }
|
||||||
|
ulid = { workspace = true }
|
||||||
|
warp = { workspace = true }
|
||||||
|
|
||||||
|
# boilerplate
|
||||||
|
derive_more = { workspace = true }
|
||||||
|
|
||||||
|
# file watcher
|
||||||
|
inotify = { workspace = true }
|
||||||
|
|
||||||
|
# # Actors
|
||||||
|
# actix = { workspace = true }
|
||||||
|
# actix-rt = { workspace = true }
|
||||||
|
tokio = { workspace = true }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
# Testing
|
||||||
|
assert2 = { workspace = true }
|
||||||
|
|
||||||
|
[lints.clippy]
|
||||||
|
nursery = { level = "warn", priority = -1 }
|
||||||
|
# pedantic = "warn"
|
||||||
|
unwrap_used = "warn"
|
||||||
|
expect_used = "warn"
|
68
crates/forge-github/src/lib.rs
Normal file
68
crates/forge-github/src/lib.rs
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
//
|
||||||
|
#![allow(dead_code)]
|
||||||
|
|
||||||
|
use derive_more::Constructor;
|
||||||
|
use git_next_config as config;
|
||||||
|
use git_next_git as git;
|
||||||
|
|
||||||
|
use kxio::network::Network;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Constructor)]
|
||||||
|
pub struct Github {
|
||||||
|
net: Network,
|
||||||
|
}
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl git_next_git::ForgeLike for Github {
|
||||||
|
fn name(&self) -> String {
|
||||||
|
"github".to_string()
|
||||||
|
}
|
||||||
|
async fn branches_get_all(&self) -> Result<Vec<config::BranchName>, git::branch::Error> {
|
||||||
|
todo!();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the contents of the file.
|
||||||
|
async fn file_contents_get(
|
||||||
|
&self,
|
||||||
|
_branch_name: &config::BranchName,
|
||||||
|
_file_path: &str,
|
||||||
|
) -> Result<String, git::file::Error> {
|
||||||
|
todo!();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Assesses the relative positions of the main, next and dev branch and updates their
|
||||||
|
/// positions as needed.
|
||||||
|
async fn branches_validate_positions(
|
||||||
|
&self,
|
||||||
|
_repository: git::OpenRepository,
|
||||||
|
_repo_config: config::RepoConfig,
|
||||||
|
) -> git::validation::Result {
|
||||||
|
todo!();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Moves a branch to a new commit.
|
||||||
|
fn branch_reset(
|
||||||
|
&self,
|
||||||
|
_repository: &git::OpenRepository,
|
||||||
|
_branch_name: config::BranchName,
|
||||||
|
_to_commit: git::GitRef,
|
||||||
|
_force: git::push::Force,
|
||||||
|
) -> git::push::Result {
|
||||||
|
todo!();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Checks the results of any (e.g. CI) status checks for the commit.
|
||||||
|
async fn commit_status(&self, _commit: &git::Commit) -> git::commit::Status {
|
||||||
|
todo!();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Clones a repo to disk.
|
||||||
|
fn repo_clone(
|
||||||
|
&self,
|
||||||
|
_gitdir: config::GitDir,
|
||||||
|
) -> Result<git::OpenRepository, git::repository::Error> {
|
||||||
|
todo!();
|
||||||
|
}
|
||||||
|
}
|
8
crates/forge-github/src/tests/mod.rs
Normal file
8
crates/forge-github/src/tests/mod.rs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
use git_next_git::ForgeLike as _;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_name() {
|
||||||
|
let net = kxio::network::Network::new_mock();
|
||||||
|
let forge = crate::Github::new(net);
|
||||||
|
assert_eq!(forge.name(), "github");
|
||||||
|
}
|
|
@ -4,14 +4,15 @@ version = { workspace = true }
|
||||||
edition = { workspace = true }
|
edition = { workspace = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["forgejo"]
|
default = ["forgejo", "github"]
|
||||||
forgejo = ["git-next-forge-forgejo"]
|
forgejo = ["git-next-forge-forgejo"]
|
||||||
github = []
|
github = ["git-next-forge-github"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
git-next-config = { workspace = true }
|
git-next-config = { workspace = true }
|
||||||
git-next-git = { workspace = true }
|
git-next-git = { workspace = true }
|
||||||
git-next-forge-forgejo = { workspace = true, optional = true }
|
git-next-forge-forgejo = { workspace = true, optional = true }
|
||||||
|
git-next-forge-github = { workspace = true, optional = true }
|
||||||
|
|
||||||
# logging
|
# logging
|
||||||
console-subscriber = { workspace = true }
|
console-subscriber = { workspace = true }
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
use crate::network::Network;
|
|
||||||
|
|
||||||
struct Github;
|
|
||||||
pub(super) struct GithubEnv {
|
|
||||||
net: Network,
|
|
||||||
}
|
|
||||||
impl GithubEnv {
|
|
||||||
pub(crate) const fn new(net: Network) -> GithubEnv {
|
|
||||||
Self { net }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[async_trait::async_trait]
|
|
||||||
impl super::ForgeLike for GithubEnv {
|
|
||||||
fn name(&self) -> String {
|
|
||||||
"github".to_string()
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn branches_get_all(&self) -> Vec<super::Branch> {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,27 +1,26 @@
|
||||||
#![allow(dead_code)]
|
//
|
||||||
|
|
||||||
use git_next_forge_forgejo as forgejo;
|
use git_next_forge_forgejo as forgejo;
|
||||||
|
use git_next_forge_github as github;
|
||||||
use git_next_git as git;
|
use git_next_git as git;
|
||||||
use kxio::network::Network;
|
use kxio::network::Network;
|
||||||
|
|
||||||
#[cfg(feature = "github")]
|
|
||||||
mod github;
|
|
||||||
|
|
||||||
mod mock_forge;
|
mod mock_forge;
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Forge {
|
pub enum Forge {
|
||||||
Mock(mock_forge::MockForgeEnv),
|
Mock(mock_forge::MockForge),
|
||||||
#[allow(clippy::enum_variant_names)]
|
|
||||||
#[cfg(feature = "forgejo")]
|
#[cfg(feature = "forgejo")]
|
||||||
ForgeJo(forgejo::ForgeJo),
|
ForgeJo(git_next_forge_forgejo::ForgeJo),
|
||||||
|
|
||||||
#[cfg(feature = "github")]
|
#[cfg(feature = "github")]
|
||||||
Github(github::GithubEnv),
|
Github(git_next_forge_github::Github),
|
||||||
}
|
}
|
||||||
impl Forge {
|
impl Forge {
|
||||||
pub const fn new_mock() -> Self {
|
pub const fn new_mock() -> Self {
|
||||||
Self::Mock(mock_forge::MockForgeEnv::new())
|
Self::Mock(mock_forge::MockForge::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "forgejo")]
|
#[cfg(feature = "forgejo")]
|
||||||
pub const fn new_forgejo(
|
pub const fn new_forgejo(
|
||||||
repo_details: git::RepoDetails,
|
repo_details: git::RepoDetails,
|
||||||
|
@ -30,9 +29,10 @@ impl Forge {
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self::ForgeJo(forgejo::ForgeJo::new(repo_details, net, repo))
|
Self::ForgeJo(forgejo::ForgeJo::new(repo_details, net, repo))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "github")]
|
#[cfg(feature = "github")]
|
||||||
pub const fn new_github(net: Network) -> Self {
|
pub const fn new_github(net: Network) -> Self {
|
||||||
Self::Github(github::GithubEnv::new(net))
|
Self::Github(github::Github::new(net))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl std::ops::Deref for Forge {
|
impl std::ops::Deref for Forge {
|
||||||
|
@ -43,7 +43,7 @@ impl std::ops::Deref for Forge {
|
||||||
#[cfg(feature = "forgejo")]
|
#[cfg(feature = "forgejo")]
|
||||||
Self::ForgeJo(env) => env,
|
Self::ForgeJo(env) => env,
|
||||||
#[cfg(feature = "github")]
|
#[cfg(feature = "github")]
|
||||||
Forge::Github(env) => env,
|
Self::Github(env) => env,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,16 @@
|
||||||
//
|
//
|
||||||
#![cfg(not(tarpaulin_include))]
|
#![cfg(not(tarpaulin_include))]
|
||||||
|
|
||||||
|
use derive_more::Constructor;
|
||||||
use git::OpenRepository;
|
use git::OpenRepository;
|
||||||
use git_next_config as config;
|
use git_next_config as config;
|
||||||
use git_next_git as git;
|
use git_next_git as git;
|
||||||
|
|
||||||
struct MockForge;
|
#[derive(Clone, Debug, Constructor)]
|
||||||
#[derive(Clone, Debug)]
|
pub struct MockForge;
|
||||||
pub struct MockForgeEnv;
|
|
||||||
impl MockForgeEnv {
|
|
||||||
pub(crate) const fn new() -> Self {
|
|
||||||
Self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl git::ForgeLike for MockForgeEnv {
|
impl git::ForgeLike for MockForge {
|
||||||
fn name(&self) -> String {
|
fn name(&self) -> String {
|
||||||
"mock".to_string()
|
"mock".to_string()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_name() {
|
|
||||||
let net = Network::new_mock();
|
|
||||||
let forge = Forge::new_github(net);
|
|
||||||
assert_eq!(forge.name(), "github");
|
|
||||||
}
|
|
|
@ -4,9 +4,6 @@ use super::*;
|
||||||
use git_next_config as config;
|
use git_next_config as config;
|
||||||
use git_next_git as git;
|
use git_next_git as git;
|
||||||
|
|
||||||
#[cfg(feature = "github")]
|
|
||||||
mod github;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_mock_name() {
|
fn test_mock_name() {
|
||||||
let forge = Forge::new_mock();
|
let forge = Forge::new_mock();
|
||||||
|
|
|
@ -22,6 +22,7 @@ impl super::OpenRepositoryLike for RealOpenRepository {
|
||||||
remote.url(direction.into()).map(Into::into)
|
remote.url(direction.into()).map(Into::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all)]
|
||||||
fn fetch(&self) -> Result<(), git::fetch::Error> {
|
fn fetch(&self) -> Result<(), git::fetch::Error> {
|
||||||
let Ok(repository) = self.0.lock() else {
|
let Ok(repository) = self.0.lock() else {
|
||||||
#[cfg(not(tarpaulin_include))] // don't test mutex lock failure
|
#[cfg(not(tarpaulin_include))] // don't test mutex lock failure
|
||||||
|
@ -44,12 +45,13 @@ impl super::OpenRepositoryLike for RealOpenRepository {
|
||||||
}
|
}
|
||||||
Err(e) => Err(git::fetch::Error::Fetch(e.to_string()))?,
|
Err(e) => Err(git::fetch::Error::Fetch(e.to_string()))?,
|
||||||
}
|
}
|
||||||
|
info!("Fetch okay");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: (#72) reimplement using `gix`
|
// TODO: (#72) reimplement using `gix`
|
||||||
#[cfg(not(tarpaulin_include))] // would require writing to external service
|
#[cfg(not(tarpaulin_include))] // would require writing to external service
|
||||||
|
#[tracing::instrument(skip_all)]
|
||||||
fn push(
|
fn push(
|
||||||
&self,
|
&self,
|
||||||
repo_details: &git::RepoDetails,
|
repo_details: &git::RepoDetails,
|
||||||
|
@ -71,13 +73,11 @@ impl super::OpenRepositoryLike for RealOpenRepository {
|
||||||
origin.expose_secret()
|
origin.expose_secret()
|
||||||
)
|
)
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
let git_dir = self
|
let git_dir = self
|
||||||
.0
|
.0
|
||||||
.lock()
|
.lock()
|
||||||
.map_err(|_| git::push::Error::Lock)
|
.map_err(|_| git::push::Error::Lock)
|
||||||
.map(|r| r.git_dir().to_path_buf())?;
|
.map(|r| r.git_dir().to_path_buf())?;
|
||||||
|
|
||||||
let ctx = gix::diff::command::Context {
|
let ctx = gix::diff::command::Context {
|
||||||
git_dir: Some(git_dir.clone()),
|
git_dir: Some(git_dir.clone()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
@ -91,7 +91,7 @@ impl super::OpenRepositoryLike for RealOpenRepository {
|
||||||
{
|
{
|
||||||
Ok(mut child) => match child.wait() {
|
Ok(mut child) => match child.wait() {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
info!("Branch updated");
|
info!("Push okay");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
@ -111,11 +111,15 @@ impl super::OpenRepositoryLike for RealOpenRepository {
|
||||||
branch_name: &config::BranchName,
|
branch_name: &config::BranchName,
|
||||||
find_commits: &[git::Commit],
|
find_commits: &[git::Commit],
|
||||||
) -> Result<Vec<crate::Commit>, git::commit::log::Error> {
|
) -> Result<Vec<crate::Commit>, git::commit::log::Error> {
|
||||||
|
let limit = match find_commits.is_empty() {
|
||||||
|
true => 1,
|
||||||
|
false => 50,
|
||||||
|
};
|
||||||
self.0
|
self.0
|
||||||
.lock()
|
.lock()
|
||||||
.map_err(|_| git::commit::log::Error::Lock)
|
.map_err(|_| git::commit::log::Error::Lock)
|
||||||
.map(|repo| {
|
.map(|repo| {
|
||||||
let branch_name = branch_name.to_string();
|
let branch_name = format!("remotes/origin/{branch_name}");
|
||||||
let branch_name = BStr::new(&branch_name);
|
let branch_name = BStr::new(&branch_name);
|
||||||
let branch_head = repo
|
let branch_head = repo
|
||||||
.rev_parse_single(branch_name)
|
.rev_parse_single(branch_name)
|
||||||
|
@ -127,7 +131,7 @@ impl super::OpenRepositoryLike for RealOpenRepository {
|
||||||
.all()
|
.all()
|
||||||
.map_err(|e| e.to_string())?;
|
.map_err(|e| e.to_string())?;
|
||||||
let mut commits = vec![];
|
let mut commits = vec![];
|
||||||
for item in walk {
|
for item in walk.take(limit) {
|
||||||
let item = item.map_err(|e| e.to_string())?;
|
let item = item.map_err(|e| e.to_string())?;
|
||||||
let commit = item.object().map_err(|e| e.to_string())?;
|
let commit = item.object().map_err(|e| e.to_string())?;
|
||||||
let id = commit.id().to_string();
|
let id = commit.id().to_string();
|
||||||
|
@ -136,12 +140,15 @@ impl super::OpenRepositoryLike for RealOpenRepository {
|
||||||
git::commit::Sha::new(id),
|
git::commit::Sha::new(id),
|
||||||
git::commit::Message::new(message),
|
git::commit::Message::new(message),
|
||||||
);
|
);
|
||||||
|
info!(?commit, "found");
|
||||||
if find_commits.contains(&commit) {
|
if find_commits.contains(&commit) {
|
||||||
|
info!("Is in find_commits");
|
||||||
commits.push(commit);
|
commits.push(commit);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
commits.push(commit);
|
commits.push(commit);
|
||||||
}
|
}
|
||||||
|
info!("finished walkfing");
|
||||||
Ok(commits)
|
Ok(commits)
|
||||||
})?
|
})?
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,13 +13,25 @@ pub struct Positions {
|
||||||
#[derive(Debug, derive_more::Display)]
|
#[derive(Debug, derive_more::Display)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
Network(Box<kxio::network::NetworkError>),
|
Network(Box<kxio::network::NetworkError>),
|
||||||
|
|
||||||
|
Fetch(git::fetch::Error),
|
||||||
|
|
||||||
#[display("Failed to Reset Branch {branch} to {commit}")]
|
#[display("Failed to Reset Branch {branch} to {commit}")]
|
||||||
FailedToResetBranch {
|
FailedToResetBranch {
|
||||||
branch: BranchName,
|
branch: BranchName,
|
||||||
commit: git::Commit,
|
commit: git::Commit,
|
||||||
},
|
},
|
||||||
|
|
||||||
BranchReset(BranchName),
|
BranchReset(BranchName),
|
||||||
|
|
||||||
BranchHasNoCommits(BranchName),
|
BranchHasNoCommits(BranchName),
|
||||||
|
|
||||||
DevBranchNotBasedOn(BranchName),
|
DevBranchNotBasedOn(BranchName),
|
||||||
}
|
}
|
||||||
impl std::error::Error for Error {}
|
impl std::error::Error for Error {}
|
||||||
|
|
||||||
|
impl From<git::fetch::Error> for Error {
|
||||||
|
fn from(value: git::fetch::Error) -> Self {
|
||||||
|
Self::Fetch(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ version = { workspace = true }
|
||||||
edition = { workspace = true }
|
edition = { workspace = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["forgejo"]
|
default = ["forgejo", "github"]
|
||||||
forgejo = []
|
forgejo = []
|
||||||
github = []
|
github = []
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,6 @@ name = "git-next-server"
|
||||||
version = { workspace = true }
|
version = { workspace = true }
|
||||||
edition = { workspace = true }
|
edition = { workspace = true }
|
||||||
|
|
||||||
[features]
|
|
||||||
default = ["forgejo"]
|
|
||||||
forgejo = []
|
|
||||||
github = []
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
git-next-config = { workspace = true }
|
git-next-config = { workspace = true }
|
||||||
git-next-git = { workspace = true }
|
git-next-git = { workspace = true }
|
||||||
|
|
Loading…
Reference in a new issue