Skip to content
Newer
Older
100644 70 lines (57 sloc) 2.12 KB
9664533 @cespare Initial sketch of multi-repo support. BREAKS STUFF.
cespare authored Aug 22, 2011
1 require "lib/meta_repo"
79349fe @dmac Formalize StringFilter contract to make it more extendable
dmac authored Oct 9, 2011
2 require "lib/string_filter"
9664533 @cespare Initial sketch of multi-repo support. BREAKS STUFF.
cespare authored Aug 23, 2011
3
cca167a @philc Add an approved_at timestamp to the commits table
philc authored Aug 21, 2011
4 # Columns:
5 # - approved_at: when the commit was approved.
6 # - approved_by_user_id: the most recent user to approve the commit.
ceeaa14 @bo-chen Models for comments
bo-chen authored Aug 3, 2011
7 class Commit < Sequel::Model
79349fe @dmac Formalize StringFilter contract to make it more extendable
dmac authored Oct 10, 2011
8 include StringFilter
9
70ad30f @cespare Things are slightly less broken. So that's nice.
cespare authored Aug 24, 2011
10 many_to_one :git_repo
e9607eb @bo-chen Rename files table to avoid namespace clashes
bo-chen authored Aug 3, 2011
11 one_to_many :commit_files
ceeaa14 @bo-chen Models for comments
bo-chen authored Aug 4, 2011
12 one_to_many :comments
26d6870 @philc Include when the commit was approved underneath the approve button.
philc authored Aug 21, 2011
13 many_to_one :approved_by_user, :class => User
3facfc0 @bo-chen Minor refactoring to expose commit/comment objects to diff view
bo-chen authored Aug 4, 2011
14
6b01502 @philc When destroying a Commit, delete entries in associated tables.
philc authored Oct 1, 2011
15 add_association_dependencies :comments => :destroy, :commit_files => :delete
16
79349fe @dmac Formalize StringFilter contract to make it more extendable
dmac authored Oct 10, 2011
17 add_filter(:message) { |message| StringFilter.escape_html(message) }
f50404c @cespare Reorder commit message filtering to fix sha linking problem (and test).
cespare authored Feb 7, 2012
18 add_filter(:message) do |message, commit|
19 StringFilter.replace_shas_with_links(message, commit.git_repo.name)
20 end
79349fe @dmac Formalize StringFilter contract to make it more extendable
dmac authored Oct 10, 2011
21 add_filter(:message) { |message| StringFilter.newlines_to_html(message) }
22 add_filter(:message) do |message, commit|
23 StringFilter.link_github_issue(message, "ooyala", commit.git_repo.name)
24 end
25 add_filter(:message) { |message| StringFilter.link_jira_issue(message) }
26
9664533 @cespare Initial sketch of multi-repo support. BREAKS STUFF.
cespare authored Aug 23, 2011
27 def grit_commit
da685ad @philc Make the MetaRepo module a class, so it can be instantiated and thus …
philc authored Sep 4, 2011
28 @grit_commit ||= MetaRepo.instance.grit_commit(git_repo_id, sha)
9664533 @cespare Initial sketch of multi-repo support. BREAKS STUFF.
cespare authored Aug 23, 2011
29 end
ef7bb01 @philc Add a todo to clean up this model.
philc authored Aug 9, 2011
30
747fa99 @dmac Remove commit.user association
dmac authored Jan 28, 2012
31
0acd6af @cespare Renamed Commit#commit_comments to less redundant Commit#comments
cespare authored Sep 26, 2011
32 def comments
6f668cf @dmac don't show line comments in alongside commit-level comments
dmac authored Aug 25, 2011
33 comments_dataset.filter(:commit_id => id, :line_number => nil).order(:created_at).all
3facfc0 @bo-chen Minor refactoring to expose commit/comment objects to diff view
bo-chen authored Aug 4, 2011
34 end
26d6870 @philc Include when the commit was approved underneath the approve button.
philc authored Aug 22, 2011
35
6becf6e @cespare Comment count indicator for saved search.
cespare authored Sep 27, 2011
36 # Total comments of all types pertaining to this commit (line comments + commit comments)
37 def comment_count
38 comments_dataset.filter(:commit_id => id).order(:created_at).count
39 end
40
26d6870 @philc Include when the commit was approved underneath the approve button.
philc authored Aug 22, 2011
41 def approved?() !approved_by_user_id.nil? end
42
43 def approve(user)
44 self.approved_at = Time.now
45 self.approved_by_user_id = user.id
46 save
47 end
48
49 def disapprove
50 self.approved_at = nil
51 self.approved_by_user_id = nil
52 save
53 end
22a966e @cespare Move sha prefix matching functionality to Commit in preparation to re…
cespare authored Dec 7, 2011
54
55 # Attempt to prefix-match a SHA
d1b621f Issue 157. Allow search by commit sha or prefix.
Manish Khettry authored Jan 20, 2012
56 def self.prefix_match(git_repo, partial_sha, zero_commits_ok=false)
22a966e @cespare Move sha prefix matching functionality to Commit in preparation to re…
cespare authored Dec 8, 2011
57 raise "No such repository: #{git_repo}" unless GitRepo[:name => git_repo]
58 commits = Commit.join(:git_repos, :id => :git_repo_id).
59 filter(:git_repos__name => git_repo).
60 filter(:sha.like("#{partial_sha}%")).limit(2).all
61 raise "Ambiguous commit in #{git_repo}: #{partial_sha}" if commits.size > 1
d1b621f Issue 157. Allow search by commit sha or prefix.
Manish Khettry authored Jan 21, 2012
62 if (commits.empty?)
63 raise "No such commit in #{git_repo}: #{partial_sha}" unless zero_commits_ok
64 nil
65 else
66 commits[0]
67 end
22a966e @cespare Move sha prefix matching functionality to Commit in preparation to re…
cespare authored Dec 8, 2011
68 end
ceeaa14 @bo-chen Models for comments
bo-chen authored Aug 4, 2011
69 end
Something went wrong with that request. Please try again.