pub struct PullRequest {
pub title: String,
pub body: String,
pub milestone: Option<Milestone>,
pub author: Option<Person>,
pub commits: Vec<PullCommit>,
}Expand description
A pull request, as gh pr view --json title,body,milestone,author,commits
gives it.
Fields§
§title: StringThe title. The squash commit gets it, and the number.
body: StringThe body. The squash commit gets it as its message.
milestone: Option<Milestone>The milestone, or None.
The author of the pull request. The squash commit is its work, so it is not a co-author.
commits: Vec<PullCommit>The commits of the pull request.
Implementations§
Source§impl PullRequest
impl PullRequest
Sourcepub fn new(title: &str, body: &str, milestone: Option<&str>) -> Self
pub fn new(title: &str, body: &str, milestone: Option<&str>) -> Self
A pull request with a title, a body and a milestone, and no co-author.
Sourcepub fn with_commit_by(self, author: Person) -> Self
pub fn with_commit_by(self, author: Person) -> Self
The same pull request with one more commit by author.
The lines Co-authored-by: Name <email> that GitHub adds to the
squash commit: one for each author of a commit, except the author
of the pull request, and each one once.
use hygiene::{Person, PullRequest};
let person = |login: &str, name: &str, email: &str| Person {
login: login.into(),
name: name.into(),
email: email.into(),
};
let pr = PullRequest::new("T", "Text.", None)
.by(person("ana", "Ana", "ana@example.com"))
.with_commit_by(person("ana", "Ana", "ana@example.com"))
.with_commit_by(person("", "GLM-5.3-Flash", "noreply@z.ai"))
.with_commit_by(person("", "GLM-5.3-Flash", "noreply@z.ai"));
assert_eq!(pr.co_authors(), ["Co-authored-by: GLM-5.3-Flash <noreply@z.ai>"]);Sourcepub fn squash_message(&self) -> String
pub fn squash_message(&self) -> String
The message that the squash will make from the body: the body, with
each line over MERGE_WIDTH wrapped as the merge wraps it
(merge_wrap), then the lines of PullRequest::co_authors in a
paragraph of their own. GitHub adds them after a blank line, also
when the body ends with trailers.
use hygiene::{Person, PullRequest};
let glm = Person { name: "GLM".into(), email: "noreply@z.ai".into(), ..Person::default() };
let pr = PullRequest::new("T", "Text.\n\nIssue: #7\n", None).with_commit_by(glm);
assert_eq!(
pr.squash_message(),
"Text.\n\nIssue: #7\n\nCo-authored-by: GLM <noreply@z.ai>\n"
);Trait Implementations§
Source§impl Clone for PullRequest
impl Clone for PullRequest
Source§fn clone(&self) -> PullRequest
fn clone(&self) -> PullRequest
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more