Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git-changelog: option to only use merges #471

Merged
merged 1 commit into from Oct 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 16 additions & 5 deletions bin/git-changelog
Expand Up @@ -4,6 +4,8 @@ DEF_TAG_RECENT="n.n.n"
GIT_LOG_OPTS="$(git config changelog.opts)"
GIT_LOG_FORMAT="$(git config changelog.format)"
[[ -z "$GIT_LOG_FORMAT" ]] && GIT_LOG_FORMAT=' * %s'
GIT_MERGELOG_FORMAT="$(git config changelog.mergeformat)"
[[ -z "$GIT_MERGELOG_FORMAT" ]] && GIT_MERGELOG_FORMAT=' * %s%n%w(64,4,4)%b'
GIT_EDITOR="$(git var GIT_EDITOR)"
PROGNAME="git-changelog"

Expand All @@ -26,6 +28,7 @@ OPTIONS:
-f, --final-tag Newest tag to retrieve commits from in a range
-s, --start-tag Oldest tag to retrieve commits from in a range
-n, --no-merges Suppress commits from merged branches
-m, --merges-only Only uses merge commits (uses both subject and body of commit)
-p, --prune-old Replace existing Changelog entirely with new content
-x, --stdout Write output to stdout instead of to a Changelog file
-h, --help, ? Show this message
Expand Down Expand Up @@ -143,13 +146,13 @@ _fetchCommitRange() {
local final_tag="$3"

if [[ "$list_all" == true ]]; then
git log $GIT_LOG_OPTS --pretty=format:"${GIT_LOG_FORMAT}"
git log $GIT_LOG_OPTS --pretty=format:"${CUR_GIT_LOG_FORMAT}"
elif [[ -n "$final_tag" && "$start_tag" == "null" ]]; then
git log $GIT_LOG_OPTS --pretty=format:"${GIT_LOG_FORMAT}" "${final_tag}"
git log $GIT_LOG_OPTS --pretty=format:"${CUR_GIT_LOG_FORMAT}" "${final_tag}"
elif [[ -n "$final_tag" ]]; then
git log $GIT_LOG_OPTS --pretty=format:"${GIT_LOG_FORMAT}" "${start_tag}"'..'"${final_tag}"
git log $GIT_LOG_OPTS --pretty=format:"${CUR_GIT_LOG_FORMAT}" "${start_tag}"'..'"${final_tag}"
elif [[ -n "$start_tag" ]]; then
git log $GIT_LOG_OPTS --pretty=format:"${GIT_LOG_FORMAT}" "${start_tag}"'..'
git log $GIT_LOG_OPTS --pretty=format:"${CUR_GIT_LOG_FORMAT}" "${start_tag}"'..'
fi | sed 's/^ \* \*/ */g'
}

Expand Down Expand Up @@ -375,6 +378,11 @@ main() {
;;
-n | --no-merges )
GIT_LOG_OPTS='--no-merges'
CUR_GIT_LOG_FORMAT="$GIT_LOG_FORMAT"
;;
-m | --merges-only )
GIT_LOG_OPTS='--merges'
CUR_GIT_LOG_FORMAT="$GIT_MERGELOG_FORMAT"
;;
-p | --prune-old )
option=( $(_setValueForKeyFakeAssocArray "prune_old" true "${option[*]}") )
Expand All @@ -393,7 +401,10 @@ main() {
esac
shift
done


# The default log format unless already set
[[ -z "$CUR_GIT_LOG_FORMAT" ]] && CUR_GIT_LOG_FORMAT="$GIT_LOG_FORMAT"

local _tag="$(_valueForKeyFakeAssocArray "start_tag" "${option[*]}")"
if [[ -n "${_tag}" ]]; then
start_tag="$(git describe --tags --abbrev=0 "${_tag}" 2>/dev/null)"
Expand Down
4 changes: 4 additions & 0 deletions man/git-changelog.md
Expand Up @@ -42,6 +42,10 @@ git-changelog(1) -- Generate a changelog report

Filters out merge commits (commits with more than 1 parent) from generated changelog.

-m, --merges-only

Uses only merge commits (commits with more than 1 parent) for generated changelog. It also changes the default format to include the merge commit messages body, as on github the commits subject line only contains the branch name but no information about the content of the merge.

-p, --prune-old

Replace existing changelog entirely with newly generated content, thereby disabling the default behavior of appending the content of any detected changelog to the end of newly generated content.
Expand Down