Support pulling out the original base commit
This commit is contained in:
parent
c283492fa7
commit
aa78e83aca
|
@ -71,6 +71,24 @@ impl PullRequest {
|
|||
&self.base.gitref
|
||||
}
|
||||
|
||||
/// The base commit of the branch is stored in the pull request for later.
|
||||
/// This digs it out if possible.
|
||||
/// There is a timestamp included.
|
||||
pub fn base_commit(&self) -> Option<(&str, u64)> {
|
||||
let regex = Regex::new("git-stack-base-commit:([a-z0-9]+)@([0-9]+)").unwrap();
|
||||
self.body
|
||||
.as_ref()
|
||||
.map(|body| {
|
||||
regex.captures(&body).map(|re_match| {
|
||||
(
|
||||
re_match.get(1).unwrap().as_str(),
|
||||
re_match[2].parse().unwrap(),
|
||||
)
|
||||
})
|
||||
})
|
||||
.flatten()
|
||||
}
|
||||
|
||||
/// Stored version of the base branch in the pull request body.
|
||||
/// Needed for when the original branch is merged and so it vanishes.
|
||||
pub fn base_branch_orig(&self) -> Option<&str> {
|
||||
|
|
Loading…
Reference in New Issue