Skip to content

Instantly share code, notes, and snippets.

@UnderpantsGnome
Created June 1, 2009 00:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save UnderpantsGnome/121111 to your computer and use it in GitHub Desktop.
Save UnderpantsGnome/121111 to your computer and use it in GitHub Desktop.
diff --git a/lib/integrity/project.rb b/lib/integrity/project.rb
index 0c67b68..49ec71a 100644
--- a/lib/integrity/project.rb
+++ b/lib/integrity/project.rb
@@ -60,23 +60,29 @@ module Integrity
private
def find_or_create_commit_with_identifier(identifier)
- # We abuse +committed_at+ here setting it to Time.now because we use it
- # to sort (for last_commit and previous_commits). I don't like this
- # very much, but for now it's the only solution I can find.
- #
- # This also creates a dependency, as now we *always* have to update the
- # +committed_at+ field after building to ensure the date is correct :(
- #
- # This might also make your commit listings a little jumpy, if some
- # commits change place every time a build finishes =\
- commits.first_or_create({:identifier => identifier, :project_id => id},
- :committed_at => Time.now)
+ # NOTE: I saw remote_repo.info(identifier) return false for one of my
+ # projects, not sure why so this is in here for now.
+ begin
+ committed_at = remote_repo.info(identifier)[:committed_at]
+ rescue Exception => e
+ Integrity.log("got #{e} when trying to fetch the remote committed_at. Falling back to Time.new")
+ committed_at = Time.new.to_s
+ end
+ commits.first_or_create({ :identifier => identifier, :project_id => id },
+ :committed_at => committed_at)
end
def head_of_remote_repo
SCM.new(uri, branch).head
end
+ def remote_repo
+ SCM.new(uri, branch,
+ Integrity.config[:export_directory] /
+ "#{SCM.working_tree_path(uri)}-#{branch}"
+ )
+ end
+
def set_permalink
attribute_set(:permalink, (name || "").downcase.
gsub(/'s/, "s").
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment