Compare commits

..

No commits in common. "394a9395a0933ddf0b6aaeb46ca704ca0f3fe940" and "d70baa4350f175a32e25eb3689184ac595c98bd6" have entirely different histories.

7 changed files with 30 additions and 35 deletions

View file

@ -1,6 +0,0 @@
on: [push]
jobs:
test:
runs-on: docker
steps:
- run: echo All Good

View file

@ -1,10 +1,16 @@
#[derive(Clone, Debug, PartialEq, Eq, derive_more::Constructor, derive_more::Display)] #[derive(Clone, Debug, PartialEq, Eq, derive_more::Display)]
#[display("{}", sha)] #[display("{}", sha)]
pub struct Commit { pub struct Commit {
sha: Sha, sha: Sha,
message: Message, message: Message,
} }
impl Commit { impl Commit {
pub fn new(sha: &str, message: &str) -> Self {
Self {
sha: Sha::new(sha.to_string()),
message: Message::new(message.to_string()),
}
}
pub const fn sha(&self) -> &Sha { pub const fn sha(&self) -> &Sha {
&self.sha &self.sha
} }
@ -13,8 +19,18 @@ impl Commit {
} }
} }
#[derive(Clone, Debug, PartialEq, Eq, derive_more::Constructor, derive_more::Display)] #[derive(Clone, Debug, PartialEq, Eq, derive_more::Display)]
pub struct Sha(String); pub struct Sha(String);
impl Sha {
pub const fn new(value: String) -> Self {
Self(value)
}
}
#[derive(Clone, Debug, PartialEq, Eq, derive_more::Constructor, derive_more::Display)] #[derive(Clone, Debug, PartialEq, Eq, derive_more::Display)]
pub struct Message(String); pub struct Message(String);
impl Message {
pub const fn new(value: String) -> Self {
Self(value)
}
}

View file

@ -1,7 +1,7 @@
use crate::Commit; use crate::Commit;
#[derive(Clone, Debug, Hash, PartialEq, Eq, derive_more::Display)] #[derive(Clone, Debug, Hash, PartialEq, Eq, derive_more::Display)]
pub struct GitRef(String); pub struct GitRef(pub String);
impl From<Commit> for GitRef { impl From<Commit> for GitRef {
fn from(value: Commit) -> Self { fn from(value: Commit) -> Self {
Self(value.sha().to_string()) Self(value.sha().to_string())

View file

@ -1,12 +1,15 @@
use git_next_config::{Hostname, RepoPath}; use git_next_config::{Hostname, RepoPath};
#[derive(Clone, Debug, PartialEq, Eq, derive_more::Constructor, derive_more::Display)] #[derive(Clone, Debug, PartialEq, Eq, derive_more::Display)]
#[display("{}:{}", host, repo_path)] #[display("{}:{}", host, repo_path)]
pub struct GitRemote { pub struct GitRemote {
host: Hostname, host: Hostname,
repo_path: RepoPath, repo_path: RepoPath,
} }
impl GitRemote { impl GitRemote {
pub const fn new(host: Hostname, repo_path: RepoPath) -> Self {
Self { host, repo_path }
}
pub const fn host(&self) -> &Hostname { pub const fn host(&self) -> &Hostname {
&self.host &self.host
} }

View file

@ -6,25 +6,13 @@ mod branch {
#[actix_rt::test] #[actix_rt::test]
async fn test_find_next_commit_on_dev() { async fn test_find_next_commit_on_dev() {
let next = git::Commit::new( let next = git::Commit::new("current-next", "foo");
git::commit::Sha::new("current-next".to_string()), let expected = git::Commit::new("dev-next", "next-should-go-here");
git::commit::Message::new("foo".to_string()),
);
let expected = git::Commit::new(
git::commit::Sha::new("dev-next".to_string()),
git::commit::Message::new("next-should-go-here".to_string()),
);
let dev_commit_history = vec![ let dev_commit_history = vec![
git::Commit::new( git::Commit::new("dev", "future"),
git::commit::Sha::new("dev".to_string()),
git::commit::Message::new("future".to_string()),
),
expected.clone(), expected.clone(),
next.clone(), next.clone(),
git::Commit::new( git::Commit::new("current-main", "history"),
git::commit::Sha::new("current-main".to_string()),
git::commit::Message::new("history".to_string()),
),
]; ];
let next_commit = find_next_commit_on_dev(next, dev_commit_history); let next_commit = find_next_commit_on_dev(next, dev_commit_history);

View file

@ -301,10 +301,7 @@ impl Push {
} }
pub fn commit(&self) -> git::Commit { pub fn commit(&self) -> git::Commit {
git::Commit::new( git::Commit::new(&self.after, &self.head_commit.message)
git::commit::Sha::new(self.after.clone()),
git::commit::Message::new(self.head_commit.message.clone()),
)
} }
} }

View file

@ -254,9 +254,6 @@ struct RepoCommit {
} }
impl From<Commit> for git::Commit { impl From<Commit> for git::Commit {
fn from(value: Commit) -> Self { fn from(value: Commit) -> Self {
Self::new( Self::new(&value.sha, &value.commit.message)
git::commit::Sha::new(value.sha),
git::commit::Message::new(value.commit.message),
)
} }
} }