Commit d586d18a904c7323ed021bf6eaf8b1cccf113f42

Check if the graph needs to be regenerated (using the commit count)

Commit diff

lib/gitorious/graphs/builder.rb

 
1515 def self.graph_dir
1616 File.join(RAILS_ROOT, "public/images/graphs/")
1717 end
18
19 def self.construct_filename(repository, branch, name)
20 "#{repository.project.slug}_#{repository.name}_#{branch}_#{name}.png"
21 end
22
23 def self.status_file(repository, branch = "master")
24 File.join(RAILS_ROOT, "tmp", "graph_generator",
25 "#{repository.project.slug}_#{repository.name}_#{repository.git.commit_count(branch)}_#{self.name}.status")
26 end
1827
1928 def self.default_theme
2029 {
toggle raw diff

lib/gitorious/graphs/commits_builder.rb

 
33
44 class CommitsBuilder < Gitorious::Graphs::Builder
55 def self.generate_for(repository)
6 if repository.has_commits?
7 builder = new(repository, repository.head_candidate.name)
6 head = repository.head_candidate
7 return if head.nil?
8
9 branch = head.name
10 if !File.exist?(self.status_file(repository, branch)) && repository.has_commits?
11 builder = new(repository, branch)
812 builder.build
913 builder.write
14 FileUtils.touch(self.status_file(repository, branch))
1015 end
1116 end
1217
3838 @graph.labels = build_labels(week_numbers)
3939 end
4040
41 def self.filename(repository, branch)
42 Builder.construct_filename(repository, branch, "commit_count")
43 end
44
4145 def construct_filename
42 "#{@repository.project.slug}_#{@repository.name}_#{@branch}_commit_count.png"
46 CommitsBuilder.filename(@repository, @branch)
4347 end
4448
4549 private
toggle raw diff

lib/gitorious/graphs/commits_by_author_builder.rb

 
55 def self.generate_for(repository)
66 if repository.has_commits?
77 repository.git.heads.each do |head|
8 builder = new(repository, head.name)
9 builder.build
10 builder.write
8 branch = head.name
9 if !File.exist?(self.status_file(repository, branch))
10 builder = new(repository, branch)
11 builder.build
12 builder.write
13 FileUtils.touch(self.status_file(repository, branch))
14 end
1115 end
1216 end
1317 end
3535 end
3636 end
3737
38 def self.filename(repository, branch)
39 Builder.construct_filename(repository, branch, "commit_count_by_author")
40 end
41
3842 def construct_filename
39 "#{@repository.project.slug}_#{@repository.name}_#{@branch}_commit_count_by_author.png"
43 CommitsByAuthorBuilder.filename(@repository, @branch)
4044 end
4145 end
4246
toggle raw diff

script/graph_generator

 
88log.level = Logger::INFO
99log.formatter.datetime_format = "%Y-%m-%d %H:%M:%S"
1010
11tmpdir = File.join(RAILS_ROOT, "tmp", "graph_generator")
12if !File.directory?(tmpdir)
13 FileUtils.mkdir_p(tmpdir)
14else
15
16end
17
1118log.info "Starting graph generation run..."
1219Repository.find(:all).each_with_index do |repository, index|
1320 begin
toggle raw diff