tangled
alpha
login
or
join now
davidpdrsn.tngl.sh
/
jj-sync-prs
1
fork
atom
this repo has no description
1
fork
atom
overview
issues
pulls
2
pipelines
Show commit messages in template
davidpdrsn.tngl.sh
3 months ago
656213ce
dbef0670
+41
-4
1 changed file
expand all
collapse all
unified
split
src
main.rs
+41
-4
src/main.rs
···
489
489
branch: &str,
490
490
target: &str,
491
491
) -> color_eyre::Result<Option<(String, String)>> {
492
492
+
use std::fmt::Write;
493
493
+
492
494
let body = std::fs::read_to_string(".github/pull_request_template.md")
493
495
.unwrap_or_else(|_| "...and description here".to_owned());
494
496
···
497
499
["diff", "--git", "-r", &format!("{target}..{branch}")],
498
500
)?;
499
501
502
502
+
let count = command(
503
503
+
"jj",
504
504
+
["log", "--count", "-r", &format!("{target}..{branch}")],
505
505
+
)?
506
506
+
.trim()
507
507
+
.parse::<i32>()?;
508
508
+
500
509
let ignored_marker = "Everything below this line will be ignored";
501
510
502
502
-
if let Some(text) = Editor::new().extension(".jjdescription").edit(&format!(
503
503
-
"Enter PR title...\n\n{body}\n\
504
504
-
JJ: {ignored_marker}\n\n{diff}"
505
505
-
))? {
511
511
+
let commit_descriptions = command(
512
512
+
"jj",
513
513
+
[
514
514
+
"log",
515
515
+
"--no-graph",
516
516
+
"-r",
517
517
+
&format!("{target}..{branch}"),
518
518
+
"-T",
519
519
+
"description ++ \"\n\"",
520
520
+
],
521
521
+
)?;
522
522
+
let commit_descriptions = commit_descriptions.trim().to_owned();
523
523
+
524
524
+
let mut template = if count == 1 {
525
525
+
commit_descriptions.clone()
526
526
+
} else {
527
527
+
format!("Enter PR title...\n\n{body}")
528
528
+
};
529
529
+
writeln!(&mut template)?;
530
530
+
writeln!(&mut template)?;
531
531
+
writeln!(&mut template, "JJ: {ignored_marker}")?;
532
532
+
if count != 1 {
533
533
+
writeln!(&mut template)?;
534
534
+
write!(&mut template, "{commit_descriptions}")?;
535
535
+
}
536
536
+
if !diff.trim().is_empty() {
537
537
+
writeln!(&mut template)?;
538
538
+
writeln!(&mut template)?;
539
539
+
writeln!(&mut template, "{diff}")?;
540
540
+
}
541
541
+
542
542
+
if let Some(text) = Editor::new().extension(".jjdescription").edit(&template)? {
506
543
if text.trim().is_empty() {
507
544
bail!("empty PR title and description");
508
545
}