Skip to content

Commit

Permalink
Can define a project-specific template by creating a file called
Browse files Browse the repository at this point in the history
<adr-dir>/templates/template.md.
  • Loading branch information
npryce committed Feb 28, 2016
1 parent aa86a8a commit b6df631
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/adr-new
Original file line number Diff line number Diff line change
Expand Up @@ -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="$@"

Expand Down
38 changes: 38 additions & 0 deletions tests/project-specific-template.expected
Original file line number Diff line number Diff line change
@@ -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

22 changes: 22 additions & 0 deletions tests/project-specific-template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
adr init adrs
mkdir -p adrs/templates
cat > adrs/templates/template.md <<EOF
# TITLE
Project specific template!
# Status
STATUS
# Info
ADR Number: NUMBER
Date: DATE
EOF
adr new Aaa Bbb
adr new Ccc Ddd
cat adrs/0002-aaa-bbb.md
cat adrs/0003-ccc-ddd.md

0 comments on commit b6df631

Please sign in to comment.