Commit 0449ef54f04090a94a8e508a98490a694d721b6a

Only save commit events for repository committers

This commmit should avoid events like:

johan committed 5e61707e to gitorious/patcitos-clone-latest

since johan is not actually a committer of gitorious/patcitos-clone-latest

Signed-off-by: David A. Cuadrado <krawek@gmail.com>

Commit diff

data/hooks/post-receive

 
77require 'date'
88
99gitdir = File.expand_path(File.join(incpath, ".."))
10repository_name = File.basename(gitdir)
11slug = ""
10repository = Repository.find_by_path(gitdir)
1211
13if repository_name =~ /\.git$/
14 repository_name.sub!(/\.git$/, "")
15 slug = File.basename(File.expand_path(File.join(gitdir, "..")))
16end
17
18project = Project.find_by_slug(slug)
19repository = nil
20
21if project.nil?
22 $stderr.puts "Unknown project: '#{slug}'"
12if repository.nil?
13 $stderr.puts "Unknown repository"
2314 exit 0
2415end
2516
26project.repositories.each { |repo|
27 if repo.name == repository_name
28 repository = repo
29 break
30 end
31}
32
17project = repository.project
3318git = Grit::Git.new(gitdir)
3419
3520while line = gets
6464 end
6565 end
6666
67 users = User.find(:all, :conditions => ["email in (?)", emails])
67 users = repository.committers.find(:all, :conditions => ["email in (?)", emails])
6868 user_map = users.inject({}) { |hash, user| hash[user.email] = user; hash }
6969
7070 revs.each do |sha1|
130130
131131 next unless action_id
132132
133 # puts "#{hash[:author]}: #{Action.name(action_id)} #{ref} on #{slug} [#{hash[:date]}]"
134 # puts " #{hash[:message]}"
135
136133 project.create_event(action_id, repository, user, ref, hash[:message], hash[:date])
137134 action = :update
138135 end
toggle raw diff