-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
60 additions
and
7 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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use crate::{ | ||
core::{save_note, apply}, | ||
git::Git, | ||
parser::{commits_to_string, instruction_from_string}, | ||
}; | ||
use clap::Args; | ||
|
||
#[derive(Debug, Args)] | ||
pub struct Apply {} | ||
|
||
const COMMENTS: &str = r#" | ||
# Here is how to use yggit | ||
# | ||
# Commands: | ||
# -> <branch> add a branch to the above commit | ||
# -> <origin>:<branch> add a branch to the above commit | ||
# | ||
# What happens next? | ||
# - All branches are pushed on origin, except if you specified a custom origin | ||
# | ||
# It's not a rebase, you can't edit commits nor reorder them | ||
"#; | ||
|
||
impl Apply { | ||
pub fn execute(&self, git: Git) -> Result<(), ()> { | ||
let commits = git.list_commits(); | ||
let output = commits_to_string(commits); | ||
|
||
let file_path = "/tmp/yggit"; | ||
|
||
let output = format!("{}\n{}", output, COMMENTS); | ||
std::fs::write(file_path, output).map_err(|_| println!("cannot write file to disk"))?; | ||
|
||
let content = git.edit_file(file_path)?; | ||
|
||
let commits = instruction_from_string(content).ok_or_else(|| { | ||
println!("Cannot parse instructions"); | ||
})?; | ||
|
||
save_note(&git, commits); | ||
|
||
apply(&git); | ||
|
||
Ok(()) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod push; | ||
pub mod show; | ||
pub mod apply; |
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
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
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
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