From b6df6313376e85ba90df512f2cfc8a502a2d75ae Mon Sep 17 00:00:00 2001 From: Nat Pryce Date: Sun, 28 Feb 2016 20:10:31 +0000 Subject: [PATCH] Can define a project-specific template by creating a file called /templates/template.md. --- src/adr-new | 10 ++++++- tests/project-specific-template.expected | 38 ++++++++++++++++++++++++ tests/project-specific-template.sh | 22 ++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 tests/project-specific-template.expected create mode 100644 tests/project-specific-template.sh diff --git a/src/adr-new b/src/adr-new index 6676c56..fbda6e4 100755 --- a/src/adr-new +++ b/src/adr-new @@ -46,8 +46,16 @@ do esac done -template=${ADR_TEMPLATE:-"$adr_template_dir/template.md"} dstdir=$("$adr_bin_dir/_adr_dir") +template="$ADR_TEMPLATE" +if [ -z $template ] +then + template="$dstdir/templates/template.md" + if [ ! -f "$template" ] + then + template="$adr_template_dir/template.md" + fi +fi title="$@" diff --git a/tests/project-specific-template.expected b/tests/project-specific-template.expected new file mode 100644 index 0000000..620fd67 --- /dev/null +++ b/tests/project-specific-template.expected @@ -0,0 +1,38 @@ ++ adr init adrs +adrs/0001-record-architecture-decisions.md ++ mkdir -p adrs/templates ++ cat ++ adr new Aaa Bbb +adrs/0002-aaa-bbb.md ++ adr new Ccc Ddd +adrs/0003-ccc-ddd.md ++ cat adrs/0002-aaa-bbb.md +# Aaa Bbb + +Project specific template! + +# Status + +Accepted + +# Info + +ADR Number: 2 + +Date: 12/01/1992 + ++ cat adrs/0003-ccc-ddd.md +# Ccc Ddd + +Project specific template! + +# Status + +Accepted + +# Info + +ADR Number: 3 + +Date: 12/01/1992 + diff --git a/tests/project-specific-template.sh b/tests/project-specific-template.sh new file mode 100644 index 0000000..9c2d73d --- /dev/null +++ b/tests/project-specific-template.sh @@ -0,0 +1,22 @@ +adr init adrs +mkdir -p adrs/templates +cat > adrs/templates/template.md <