Skip to content
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

Merged
merged 12 commits into from
Jan 30, 2015
Merged

1171 add commit model #1173

merged 12 commits into from
Jan 30, 2015

Conversation

0robustus1
Copy link
Contributor

Should fix #1171, which again should help with the completion of #1154.

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)

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]

Copy link
Contributor Author

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?

Copy link
Member

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

@0robustus1 0robustus1 assigned 0robustus1 and eugenk and unassigned 0robustus1 Jan 29, 2015
class Commit < ActiveRecord::Base
attr_accessible :commit_oid, :repository
attr_accessible :author, :author_date
attr_accessible :commit_date, :committer
Copy link
Member

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.

Different repositories could contain commits with the
same SHA, so we'll need to filter for the repository.
@eugenk
Copy link
Member

eugenk commented Jan 30, 2015

👍

0robustus1 added a commit that referenced this pull request Jan 30, 2015
@0robustus1 0robustus1 merged commit 9109616 into staging Jan 30, 2015
@0robustus1 0robustus1 deleted the 1171-add_commit_model branch January 30, 2015 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add git-commit header-fields to ontology-version
4 participants