Commit d586d18a904c7323ed021bf6eaf8b1cccf113f42
- Date: Sat Apr 12 03:49:45 +0000 2008
- Committer: David A. Cuadrado (krawek@gmail.com)
- Author: David A. Cuadrado (krawek@gmail.com)
- Commit SHA1: d586d18a904c7323ed021bf6eaf8b1cccf113f42
- Tree SHA1: e41e784bfb49bbf5504f50a0ae8a2b403b331b22
Check if the graph needs to be regenerated (using the commit count)
Commit diff
| |   |
| 15 | 15 | def self.graph_dir |
| 16 | 16 | File.join(RAILS_ROOT, "public/images/graphs/") |
| 17 | 17 | 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 |
| 18 | 27 | |
| 19 | 28 | def self.default_theme |
| 20 | 29 | { |
| toggle raw diff |
--- a/lib/gitorious/graphs/builder.rb
+++ b/lib/gitorious/graphs/builder.rb
@@ -15,6 +15,15 @@ module Gitorious
def self.graph_dir
File.join(RAILS_ROOT, "public/images/graphs/")
end
+
+ def self.construct_filename(repository, branch, name)
+ "#{repository.project.slug}_#{repository.name}_#{branch}_#{name}.png"
+ end
+
+ def self.status_file(repository, branch = "master")
+ File.join(RAILS_ROOT, "tmp", "graph_generator",
+ "#{repository.project.slug}_#{repository.name}_#{repository.git.commit_count(branch)}_#{self.name}.status")
+ end
def self.default_theme
{ |
| |   |
| 3 | 3 | |
| 4 | 4 | class CommitsBuilder < Gitorious::Graphs::Builder |
| 5 | 5 | 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) |
| 8 | 12 | builder.build |
| 9 | 13 | builder.write |
| 14 | FileUtils.touch(self.status_file(repository, branch)) |
| 10 | 15 | end |
| 11 | 16 | end |
| 12 | 17 | |
| … | … | |
| 38 | 38 | @graph.labels = build_labels(week_numbers) |
| 39 | 39 | end |
| 40 | 40 | |
| 41 | def self.filename(repository, branch) |
| 42 | Builder.construct_filename(repository, branch, "commit_count") |
| 43 | end |
| 44 | |
| 41 | 45 | def construct_filename |
| 42 | | "#{@repository.project.slug}_#{@repository.name}_#{@branch}_commit_count.png" |
| 46 | CommitsBuilder.filename(@repository, @branch) |
| 43 | 47 | end |
| 44 | 48 | |
| 45 | 49 | private |
| toggle raw diff |
--- a/lib/gitorious/graphs/commits_builder.rb
+++ b/lib/gitorious/graphs/commits_builder.rb
@@ -3,10 +3,15 @@ module Gitorious
class CommitsBuilder < Gitorious::Graphs::Builder
def self.generate_for(repository)
- if repository.has_commits?
- builder = new(repository, repository.head_candidate.name)
+ head = repository.head_candidate
+ return if head.nil?
+
+ branch = head.name
+ if !File.exist?(self.status_file(repository, branch)) && repository.has_commits?
+ builder = new(repository, branch)
builder.build
builder.write
+ FileUtils.touch(self.status_file(repository, branch))
end
end
@@ -33,8 +38,12 @@ module Gitorious
@graph.labels = build_labels(week_numbers)
end
+ def self.filename(repository, branch)
+ Builder.construct_filename(repository, branch, "commit_count")
+ end
+
def construct_filename
- "#{@repository.project.slug}_#{@repository.name}_#{@branch}_commit_count.png"
+ CommitsBuilder.filename(@repository, @branch)
end
private |
| |   |
| 5 | 5 | def self.generate_for(repository) |
| 6 | 6 | if repository.has_commits? |
| 7 | 7 | 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 |
| 11 | 15 | end |
| 12 | 16 | end |
| 13 | 17 | end |
| … | … | |
| 35 | 35 | end |
| 36 | 36 | end |
| 37 | 37 | |
| 38 | def self.filename(repository, branch) |
| 39 | Builder.construct_filename(repository, branch, "commit_count_by_author") |
| 40 | end |
| 41 | |
| 38 | 42 | def construct_filename |
| 39 | | "#{@repository.project.slug}_#{@repository.name}_#{@branch}_commit_count_by_author.png" |
| 43 | CommitsByAuthorBuilder.filename(@repository, @branch) |
| 40 | 44 | end |
| 41 | 45 | end |
| 42 | 46 | |
| toggle raw diff |
--- a/lib/gitorious/graphs/commits_by_author_builder.rb
+++ b/lib/gitorious/graphs/commits_by_author_builder.rb
@@ -5,9 +5,13 @@ module Gitorious
def self.generate_for(repository)
if repository.has_commits?
repository.git.heads.each do |head|
- builder = new(repository, head.name)
- builder.build
- builder.write
+ branch = head.name
+ if !File.exist?(self.status_file(repository, branch))
+ builder = new(repository, branch)
+ builder.build
+ builder.write
+ FileUtils.touch(self.status_file(repository, branch))
+ end
end
end
end
@@ -31,8 +35,12 @@ module Gitorious
end
end
+ def self.filename(repository, branch)
+ Builder.construct_filename(repository, branch, "commit_count_by_author")
+ end
+
def construct_filename
- "#{@repository.project.slug}_#{@repository.name}_#{@branch}_commit_count_by_author.png"
+ CommitsByAuthorBuilder.filename(@repository, @branch)
end
end
|
| |   |
| 8 | 8 | log.level = Logger::INFO |
| 9 | 9 | log.formatter.datetime_format = "%Y-%m-%d %H:%M:%S" |
| 10 | 10 | |
| 11 | tmpdir = File.join(RAILS_ROOT, "tmp", "graph_generator") |
| 12 | if !File.directory?(tmpdir) |
| 13 | FileUtils.mkdir_p(tmpdir) |
| 14 | else |
| 15 | |
| 16 | end |
| 17 | |
| 11 | 18 | log.info "Starting graph generation run..." |
| 12 | 19 | Repository.find(:all).each_with_index do |repository, index| |
| 13 | 20 | begin |
| toggle raw diff |
--- a/script/graph_generator
+++ b/script/graph_generator
@@ -8,6 +8,13 @@ log.formatter = Logger::Formatter.new
log.level = Logger::INFO
log.formatter.datetime_format = "%Y-%m-%d %H:%M:%S"
+tmpdir = File.join(RAILS_ROOT, "tmp", "graph_generator")
+if !File.directory?(tmpdir)
+ FileUtils.mkdir_p(tmpdir)
+else
+
+end
+
log.info "Starting graph generation run..."
Repository.find(:all).each_with_index do |repository, index|
begin |