File: git-debian-changelog

package info (click to toggle)
git-stuff 11-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 468 kB
  • sloc: sh: 1,072; perl: 152; makefile: 128
file content (77 lines) | stat: -rwxr-xr-x 1,897 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/sh

## Copyright (C) 2006-2011 Daniel Baumann <daniel.baumann@progress-technologies.net>
##
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.


set -e

_MODE="$(basename ${0} | awk -F- '{ print $2 }')"

# Checking arguments
case "${1}" in
	-h|--help)
		echo "git-${_MODE}-changelog - wrapper over git-dch(1)"
		echo
		echo "Usage: ${0} [ID]"

		exit 0
		;;
esac

# Checking depends
if [ ! -x "$(which git 2>/dev/null)" ]
then
	echo "E: git - No such file."
	exit 1
fi

if [ ! -x "$(which git-dch 2>/dev/null)" ]
then
	echo "E: git-dch - No such file."
	exit 1
fi

if [ ! -f debian/changelog ]
then
	echo "E: debian/changelog - No such file."
	exit 1
fi

COMMIT="${1}"

if [ -z "${COMMIT}" ]
then
	# Try to automatically get a commit id from last release commits
	if [ -n "$(git log | grep -m1 'Adding version ')" ]
	then
		COMMIT="$(git log | grep -B4 -m1 "Adding version " | awk '/^commit / { print $2 }')"
	fi

	if [ -z "${COMMIT}" ] && [ -n "$(git log | grep -m1 'Releasing version ')" ]
	then
		COMMIT="$(git log | grep -B4 -m1 "Releasing version " | awk '/^commit / { print $2 }')"
	fi

	if [ -z "${COMMIT}" ] && [ -n "$(git log | grep -m1 "Adding ${_MODE} version ")" ]
	then
		COMMIT="$(git log | grep -B4 -m1 "Adding ${_MODE} version " | awk '/^commit / { print $2 }')"
	fi

	if [ -z "${COMMIT}" ] && [ -n "$(git log | grep -m1 "Releasing ${_MODE} version ")" ]
	then
		COMMIT="$(git log | grep -B4 -m1 "Releasing ${_MODE} version " | awk '/^commit / { print $2 }')"
	fi
else
	shift
fi

if [ -n "${COMMIT}" ]
then
	git-dch --debian-branch $(git branch | awk '/^\* / { print $2 }') --git-author --release --since ${COMMIT} ${@}
else
	git-dch --auto --debian-branch $(git branch | awk '/^\* / { print $2 }') --git-author --release ${@}
fi