-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update structure and boilerplate logic
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
1 parent
f356d73
commit d3f6b16
Showing
6 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ pub mod compress; | |
pub mod consts; | ||
pub mod decompress; | ||
pub mod operations; | ||
pub mod scm; | ||
pub mod utils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
mod clone; | ||
mod describe; | ||
mod pull; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(()) | ||
} |