Skip to content

Commit

Permalink
chore: update structure and boilerplate logic
Browse files Browse the repository at this point in the history
We will use eventually or borrow/copy some code
from the examples directory of the git2-rs repository

Of course, those code will be licensed as CC0 because
it's not my code and I got lazy.

Signed-off-by: Soc Virnyl Estela <[email protected]>
  • Loading branch information
uncomfyhalomacro committed Dec 15, 2024
1 parent f356d73 commit d3f6b16
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions libroast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ pub mod compress;
pub mod consts;
pub mod decompress;
pub mod operations;
pub mod scm;
pub mod utils;
19 changes: 19 additions & 0 deletions libroast/src/scm/clone.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use git2::Repository;
use std::path::Path;

pub fn clone(
repo_url: &str,
local_clone_path: &Path,
recursive_submodules: bool,
) -> Result<Repository, git2::Error>
{
let result = if recursive_submodules
{
Repository::clone_recurse(repo_url, local_clone_path)
}
else
{
Repository::clone(repo_url, local_clone_path)
};
result
}
18 changes: 18 additions & 0 deletions libroast/src/scm/describe.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use git2::{
DescribeFormatOptions,
DescribeOptions,
Repository,
};
use std::path::Path;

pub fn describe(local_repo_path: &Path) -> Result<String, git2::Error>
{
let repository = Repository::open(local_repo_path)?;
let mut describe_options = DescribeOptions::new();
let mut describe_format_options = DescribeFormatOptions::new();
describe_options.describe_all();
describe_format_options.always_use_long_format(true);
let describe_result = repository.describe(&describe_options)?;
let ret = describe_result.format(Some(&describe_format_options));
ret
}
Empty file removed libroast/src/scm/git/opts.rs
Empty file.
3 changes: 3 additions & 0 deletions libroast/src/scm/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mod clone;
mod describe;
mod pull;
14 changes: 14 additions & 0 deletions libroast/src/scm/pull.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use git2::Repository;
use std::path::Path;

pub fn pull_new_changes(local_repo_path: &Path, remote: Option<&str>) -> Result<(), git2::Error>
{
let repository = Repository::open(local_repo_path)?;
let remote = match remote
{
Some(rem) => rem,
None => "origin",
};
let remote = repository.find_remote(remote)?;
Ok(())
}

0 comments on commit d3f6b16

Please sign in to comment.