forked from integrity/integrity
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Build into Commit and Build [integrity#61 state:resolved]
* Migrations are fixed, and should work out of the box. Just run `integrity create_db config.yml` and your database should be migrated (backup the database just in case before, and let us know if something goes wrong). * Build manually is broken if you don't have commits in your project already. If there's a build already, it will just rebuild that commit This ties into [integrity#16] but breaks a few things. Mainly building for the first time to test the config is working (before we get sent a push). * Posting to /push requires more information. All the information is already sent by Github, so no harm done if you're using that. If not, you need to provide, for each commit, a timestamp, the author name and email (in 'name <email>' format), and the commit message. We will publish a custom ruby script that you can run as your post-receive hook and that supplies all this information. * Building is still done in the foreground, but all the "dirty" work is done and making it build in background should be easy now. * Some styles and views need work. need work (at least, to handle commits that haven't been built yet), but maybe something else I'm missing.
- Loading branch information
Showing
31 changed files
with
677 additions
and
421 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
module Integrity | ||
class Commit | ||
include DataMapper::Resource | ||
|
||
property :id, Integer, :serial => true | ||
property :identifier, String, :nullable => false | ||
property :message, String, :nullable => false, :length => 255 | ||
property :author, String, :nullable => false, :length => 255 | ||
property :committed_at, DateTime, :nullable => false | ||
property :created_at, DateTime | ||
property :updated_at, DateTime | ||
|
||
belongs_to :project, :class_name => "Integrity::Project" | ||
has 1, :build, :class_name => "Integrity::Build" | ||
|
||
def short_identifier | ||
identifier.to_s[0..6] | ||
end | ||
|
||
def author | ||
@structured_author ||= attribute_get(:author).tap do |author_string| | ||
author_string =~ /^(.*) <(.*)>$/ | ||
author_string.singleton_def(:name) { $1.strip } | ||
author_string.singleton_def(:email) { $2.strip } | ||
author_string.singleton_def(:full) { author_string } | ||
end | ||
end | ||
|
||
def status | ||
build.nil? ? :pending : build.status | ||
end | ||
|
||
def successful? | ||
status == :success | ||
end | ||
|
||
def failed? | ||
status == :failed | ||
end | ||
|
||
def pending? | ||
status == :pending | ||
end | ||
|
||
def human_readable_status | ||
case status | ||
when :success; "Built #{short_identifier} successfully" | ||
when :failed; "Built #{short_identifier} and failed" | ||
when :pending; "#{short_identifier} hasn't been built yet" | ||
end | ||
end | ||
|
||
def output | ||
build && build.output | ||
end | ||
|
||
def queue_build | ||
self.build = Build.create(:commit_id => id) | ||
self.save | ||
|
||
# Build on foreground (this will move away, I promise) | ||
ProjectBuilder.new(project).build(self) | ||
end | ||
|
||
# Deprecation layer | ||
alias :short_commit_identifier :short_identifier | ||
alias :commit_identifier :identifier | ||
alias :commit_author :author | ||
alias :commit_message :message | ||
alias :commited_at :committed_at | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.