Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config/git-notifier-config.example.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# set to true if you want to ignore empty merge messages
ignore_merge: false

# If any commit in a push is a merge,
# setting this to true will ignore all non-merge commits in that push.
ignore_merge_dependencies: false

# Optional parameter for the subject-line of the mail
# emailprefix: GIT

Expand Down
10 changes: 10 additions & 0 deletions lib/git_commit_notifier/diff_to_html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ def ignore_merge?
config['ignore_merge']
end

# Gets ignore_merge_dependencies setting from {#config}.
def ignore_merge_dependencies?
config['ignore_merge_dependencies']
end

# Gets show_summary setting from {#config}.
def show_summary?
config['show_summary']
Expand Down Expand Up @@ -884,6 +889,11 @@ def diff_between_revisions(rev1, rev2, repo, ref_name)
@result.reject! { |commit| merge_commit?(commit[:commit_info]) }
end

# If any commit is a merge, ignore all non-merge commits (if requested)
if ignore_merge_dependencies? and @result.count { |commit| merge_commit?(commit[:commit_info]) } > 0
@result.select! { |commit| merge_commit?(commit[:commit_info]) }
end

# If a block was given, pass it the results, in turn
@result.each { |commit| yield @result.size, commit } if block_given?
end
Expand Down
13 changes: 9 additions & 4 deletions lib/git_commit_notifier/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ def branch_heads
end

def git_dir
from_shell("git rev-parse --git-dir").strip
@git_dir ||= from_shell("git rev-parse --git-dir").strip
end

def toplevel_dir
from_shell("git rev-parse --show-toplevel").strip
@toplevel_dir ||= from_shell("git rev-parse --absolute-git-dir").strip
end

def rev_parse(param)
Expand Down Expand Up @@ -215,18 +215,23 @@ def tag_info(refname)
# If it's not specified then returns directory name (except '.git' suffix if exists).
# @return [String] Human readable repository name.
def repo_name
return @repo_name if @repo_name

git_prefix = begin
from_shell("git config hooks.emailprefix").strip
rescue ArgumentError
''
end
return git_prefix unless git_prefix.empty?
if not git_prefix.empty?
@repo_name = git_prefix
return git_prefix
end
git_path = toplevel_dir
# In a bare repository, toplevel directory is empty. Revert to git_dir instead.
if git_path.empty?
git_path = git_dir
end
File.expand_path(git_path).split("/").last.sub(/\.git$/, '')
@repo_name = File.expand_path(git_path).split("/").last.sub(/\.git$/, '')
end

# Gets repository name.
Expand Down