-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add id command so that users would be able to explicitly add patch ids to commits in their stack. [changelog] added: id subcommand to add patch ids to commits missing patch ids <!-- ps-id: b267ff0a-e9c3-4ca8-9d95-ca21d5a18720 -->
- Loading branch information
1 parent
3934708
commit 19807d5
Showing
7 changed files
with
66 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
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,13 @@ | ||
use super::utils::print_error_chain; | ||
use gps as ps; | ||
|
||
pub fn id(color: bool) { | ||
let res = ps::id(); | ||
match res { | ||
Ok(_) => {} | ||
Err(e) => { | ||
print_error_chain(color, e.into()); | ||
std::process::exit(1); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use super::super::super::ps; | ||
use super::super::private::git; | ||
|
||
#[derive(Debug)] | ||
pub enum IdError { | ||
OpenGitConfigFailed(Box<dyn std::error::Error>), | ||
AddPatchIdsFailed(Box<dyn std::error::Error>), | ||
Unhandled(Box<dyn std::error::Error>), | ||
} | ||
|
||
impl std::fmt::Display for IdError { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
Self::OpenGitConfigFailed(e) => { | ||
write!(f, "Failed to open git config, {}", e) | ||
} | ||
Self::AddPatchIdsFailed(e) => write!(f, "add patch ids failed, {}", e), | ||
Self::Unhandled(e) => write!(f, "{}", e), | ||
} | ||
} | ||
} | ||
|
||
impl std::error::Error for IdError { | ||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { | ||
match self { | ||
Self::OpenGitConfigFailed(e) => Some(e.as_ref()), | ||
Self::AddPatchIdsFailed(e) => Some(e.as_ref()), | ||
Self::Unhandled(e) => Some(e.as_ref()), | ||
} | ||
} | ||
} | ||
|
||
pub fn id() -> Result<(), IdError> { | ||
let repo = git::create_cwd_repo().map_err(|e| IdError::Unhandled(e.into()))?; | ||
|
||
let config = | ||
git2::Config::open_default().map_err(|e| IdError::OpenGitConfigFailed(e.into()))?; | ||
|
||
ps::add_patch_ids(&repo, &config).map_err(|e| IdError::AddPatchIdsFailed(e.into())) | ||
} |
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