Commit 0449ef54f04090a94a8e508a98490a694d721b6a
- Diff rendering mode:
- inline
- side by side
data/hooks/post-receive
(5 / 23)
|   | |||
| 7 | 7 | require 'date' | |
| 8 | 8 | ||
| 9 | 9 | gitdir = File.expand_path(File.join(incpath, "..")) | |
| 10 | repository_name = File.basename(gitdir) | ||
| 11 | slug = "" | ||
| 10 | repository = Repository.find_by_path(gitdir) | ||
| 12 | 11 | ||
| 13 | if repository_name =~ /\.git$/ | ||
| 14 | repository_name.sub!(/\.git$/, "") | ||
| 15 | slug = File.basename(File.expand_path(File.join(gitdir, ".."))) | ||
| 16 | end | ||
| 17 | |||
| 18 | project = Project.find_by_slug(slug) | ||
| 19 | repository = nil | ||
| 20 | |||
| 21 | if project.nil? | ||
| 22 | $stderr.puts "Unknown project: '#{slug}'" | ||
| 12 | if repository.nil? | ||
| 13 | $stderr.puts "Unknown repository" | ||
| 23 | 14 | exit 0 | |
| 24 | 15 | end | |
| 25 | 16 | ||
| 26 | project.repositories.each { |repo| | ||
| 27 | if repo.name == repository_name | ||
| 28 | repository = repo | ||
| 29 | break | ||
| 30 | end | ||
| 31 | } | ||
| 32 | |||
| 17 | project = repository.project | ||
| 33 | 18 | git = Grit::Git.new(gitdir) | |
| 34 | 19 | ||
| 35 | 20 | while line = gets | |
| … | … | ||
| 64 | 64 | end | |
| 65 | 65 | end | |
| 66 | 66 | ||
| 67 | users = User.find(:all, :conditions => ["email in (?)", emails]) | ||
| 67 | users = repository.committers.find(:all, :conditions => ["email in (?)", emails]) | ||
| 68 | 68 | user_map = users.inject({}) { |hash, user| hash[user.email] = user; hash } | |
| 69 | 69 | ||
| 70 | 70 | revs.each do |sha1| | |
| … | … | ||
| 129 | 129 | end | |
| 130 | 130 | ||
| 131 | 131 | next unless action_id | |
| 132 | |||
| 133 | # puts "#{hash[:author]}: #{Action.name(action_id)} #{ref} on #{slug} [#{hash[:date]}]" | ||
| 134 | # puts " #{hash[:message]}" | ||
| 135 | 132 | ||
| 136 | 133 | project.create_event(action_id, repository, user, ref, hash[:message], hash[:date]) | |
| 137 | 134 | action = :update |

