-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1171 add commit model #1173
1171 add commit model #1173
Conversation
When adding or deleting a file we should create a corresponding commit object for the commit.
We should easily get all ontology_versions that were created due to a commit and all ontologies that were influenced by a commit.
This rake task will migrate the existing data to commit-objects and link ontology_versions appropriately. If we were however to remove the commit_oid field from ontology_versions we could only do so after this rake task has been run.
@@ -128,6 +131,22 @@ def create_version(ontology, commit_oid, ontology_version_options) | |||
version | |||
end | |||
|
|||
def commit_for!(commit_oid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/MethodLength: Method has too many lines. [13/10]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't really shorten it. Do you see a good way @eugenk?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about something like
def commit_for!(commit_oid)
instance = Commit.where(repository_id: self, commit_oid: commit_oid).
first_or_initialize
setup_commit_instance(instance) unless instance.persisted?
instance
end
def setup_commit_instance(instance)
commit = git.repo.lookup(instance.commit_oid)
data = commit.committer
instance.committer = "#{data[:name]} <#{data[:email]}>"
instance.commit_date = data[:time]
data = commit.author
instance.author = "#{data[:name]} <#{data[:email]}>"
instance.author_date = data[:time]
instance.save!
end
class Commit < ActiveRecord::Base | ||
attr_accessible :commit_oid, :repository | ||
attr_accessible :author, :author_date | ||
attr_accessible :commit_date, :committer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attr_accessible :committer, :commit_date
for consistency in the ordering with the author-line.
7830709
to
60797cb
Compare
60797cb
to
39aff35
Compare
Different repositories could contain commits with the same SHA, so we'll need to filter for the repository.
39aff35
to
bd52790
Compare
👍 |
Should fix #1171, which again should help with the completion of #1154.