Compare commits
No commits in common. "e77830a14440844733008539acad61fdd7b6eded" and "031aad7aa382f8b94fc4f3158709a67a957067b1" have entirely different histories.
e77830a144
...
031aad7aa3
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +0,0 @@
|
||||
.*.sw*
|
53
changelog
53
changelog
@ -8,9 +8,21 @@ CHANGELOG=/etc/changelog
|
||||
|
||||
msg(){ echo -e "$@"; }
|
||||
panic(){ msg "${@} Exiting."; exit 1;}
|
||||
ENTRY_FILE=$(mktemp)
|
||||
template(){
|
||||
t=$(mktemp)
|
||||
cat << HEREDOC >$t
|
||||
|
||||
$(date "+%Y-%m-%d %H:%M") $CHANGELOG_USERNAME
|
||||
|
||||
$( echo -e "$@"|sed 's/^/ /' )
|
||||
HEREDOC
|
||||
[[ -f $CHANGELOG ]] && cat /etc/changelog >> $t
|
||||
cat "$t" > $CHANGELOG
|
||||
rm -f "$t"
|
||||
}
|
||||
|
||||
change(){
|
||||
TMP="$1"
|
||||
local TMP=$(mktemp)
|
||||
while true ; do
|
||||
echo -e "\nType the nature of the change.\nExample: > mysql: do not start on boot\n"
|
||||
read -e -p "> " SUB
|
||||
@ -38,7 +50,8 @@ change(){
|
||||
echo -e "\nHere is the content you are about to add.\n\n$(cat $TMP)\n"
|
||||
read -e -p "OK? [Yn]: " -i y RETURN
|
||||
[[ "N" == ${RETURN^^} ]] && return
|
||||
echo $TMP
|
||||
template "$(cat $TMP)"
|
||||
rm $TMP
|
||||
}
|
||||
|
||||
hookContentComment(){
|
||||
@ -48,22 +61,6 @@ hookContentComment(){
|
||||
echo "$CONTENT" >> $TMP
|
||||
}
|
||||
|
||||
hookOutputFile(){
|
||||
[[ -z "$1" ]] && echo "Writing a local changelog entry to $CHANGELOG" && return
|
||||
local t=$(mktemp)
|
||||
TMP="$1"
|
||||
cat << HEREDOC >$t
|
||||
|
||||
$(date "+%Y-%m-%d %H:%M") $CHANGELOG_USERNAME
|
||||
|
||||
$( echo -e "$@"|sed 's/^/ /' )
|
||||
HEREDOC
|
||||
|
||||
[[ -f $CHANGELOG ]] && cat /etc/changelog >> $t
|
||||
cat "$t" > $CHANGELOG
|
||||
rm -f "$t"
|
||||
|
||||
}
|
||||
|
||||
# Exec
|
||||
|
||||
@ -76,16 +73,6 @@ for (( i = 0; i < ${#HOOKS_CONTENT[@]} ; i++ )); do
|
||||
HOOKS_CONTENT_MENU+=("$( ${HOOKS_CONTENT[$i]} )")
|
||||
done
|
||||
|
||||
# Build the hook content menu
|
||||
HOOKS_OUTPUT+=("hookOutputFile")
|
||||
declare -a HOOKS_OUTPUT_MENU
|
||||
[[ -n "hooks-output/*" ]] && source hooks-output/*
|
||||
for (( i = 0; i < ${#HOOKS_OUTPUT[@]} ; i++ )); do
|
||||
TXT=$( ${HOOKS_OUTPUT[$i]} )
|
||||
HOOKS_OUTPUT_MENU+=("$( ${HOOKS_OUTPUT[$i]} )")
|
||||
done
|
||||
|
||||
|
||||
|
||||
|
||||
echo -e "\nWelcome to Serious Changelogs Inc. Do you have something for me?\n"
|
||||
@ -97,11 +84,5 @@ echo -e "\nWelcome to Serious Changelogs Inc. Do you have something for me?\n"
|
||||
[[ ! -f $CHANGELOG ]] && template "* Changelog: Added $CHANGELOG file\nIt was not serious. Fixed!\n\n"
|
||||
|
||||
# parse command
|
||||
change "$ENTRY_FILE"
|
||||
change
|
||||
|
||||
for (( i=0; i<${#HOOKS_OUTPUT_MENU[@]}; i++)) ; do
|
||||
echo "${HOOKS_OUTPUT_MENU[$i]}"
|
||||
${HOOKS_OUTPUT[$i]} $ENTRY_FILE
|
||||
done
|
||||
|
||||
rm "$ENTRY_FILE"
|
||||
|
@ -1,15 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
HOOKS_OUTPUT+=( hookOutputChangelogServer )
|
||||
|
||||
CHANGELOG_SERVER=http://localhost:3000
|
||||
|
||||
hookOutputChangelogServer(){
|
||||
|
||||
[[ -z "$1" ]] && echo "Sending changelog to remote server" && return
|
||||
CONTENT=$(jq -aRs . $1|tr '"' '\"')
|
||||
PAYLOAD="{\"author\":\"$CHANGELOG_USERNAME\",\"server\":\"$(hostname -f)\",\"content\":${CONTENT}}"
|
||||
URL=$( curl -X POST -H "Content-Type: application/json" -s -d "${PAYLOAD}" "$CHANGELOG_SERVER/changelog/_doc"; )
|
||||
echo "$FILE: $URL" >> $TMP
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user