Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 24
- Log:
Initial import of Collaboa 0.5.6 from downloaded Tarball. Collaboa is
a Ruby On Rails based bug tracker and SVN repository browsing tool.
- Author:
- adh
- Date:
- Mon Jul 24 21:54:39 +0100 2006
- Size:
- 3898 Bytes
1 | class Changeset < ActiveRecord::Base |
2 | has_many :changes, :dependent => true |
3 | |
4 | validates_uniqueness_of :revision |
5 | |
6 | # Returns am array of "normalized" hashes, useful for mixing display of search result from |
7 | # other resources (token finder code based on things found in Typo) |
8 | def self.search(query) |
9 | if !query.to_s.strip.empty? |
10 | tokens = query.split.collect {|c| "%#{c.downcase}%"} |
11 | findings = find( :all, |
12 | :conditions => [(["(LOWER(log) LIKE ?)"] * tokens.size).join(" AND "), |
13 | *tokens.collect { |token| [token] }.flatten], |
14 | :order => 'created_at DESC') |
15 | findings.collect do |f| |
16 | { |
17 | :title => "Changeset ##{f.revision}", |
18 | :content => f.log, |
19 | :link => { :controller => '/repository', :action => 'show_changeset', :revision => f.revision } |
20 | } |
21 | end |
22 | else |
23 | [] |
24 | end |
25 | end |
26 | |
27 | # Syncronizes the database tables as needed with the repos |
28 | # This method should be called from a before filter preferably |
29 | # so that we always are in sync with the repos |
30 | def self.sync_changesets |
31 | begin |
32 | Changeset.transaction do |
33 | last_stored = Changeset.find_first(nil, "revision DESC") |
34 | if last_stored.nil? |
35 | youngest_stored = 0 |
36 | else |
37 | youngest_stored = last_stored.revision |
38 | end |
39 | youngest_rev = Repository.get_youngest_rev |
40 | |
41 | revs_to_sync = ((youngest_stored + 1)..youngest_rev).to_a |
42 | revs_to_sync.each do |rev| |
43 | revision = Repository.get_changeset(rev) |
44 | |
45 | cs = Changeset.new(:revision => rev, |
46 | :author => revision.author, |
47 | :log => revision.log_message, |
48 | :revised_at => revision.date) |
49 | |
50 | revision.copied_nodes.each do |path| |
51 | cs.changes << Change.new(:revision => rev, :name => 'CP', |
52 | :path => path[0], :from_path => path[1], |
53 | :from_revision => path[2]) |
54 | #logger.info " CP #{path[0]} (from #{path[1]}:#{path[2]})" |
55 | end |
56 | |
57 | revision.moved_nodes.each do |path| |
58 | cs.changes << Change.new(:revision => rev, :name => 'MV', |
59 | :path => path[0], :from_path => path[1], |
60 | :from_revision => path[2]) |
61 | #logger.info " MV #{path[0]} (from #{path[1]}:#{path[2]})" |
62 | end |
63 | |
64 | revision.added_nodes.each do |path| |
65 | cs.changes << Change.new(:revision => rev, :name => 'A', :path => path) |
66 | #logger.info " A #{path}" |
67 | end |
68 | |
69 | revision.deleted_nodes.each do |path| |
70 | cs.changes << Change.new(:revision => rev, :name => 'D', :path => path) |
71 | #logger.info " D #{path}" |
72 | end |
73 | |
74 | revision.updated_nodes.each do |path| |
75 | cs.changes << Change.new(:revision => rev, :name => 'M', :path => path) |
76 | #logger.info " M #{path}" |
77 | end |
78 | |
79 | cs.save! |
80 | |
81 | logger.info "* Synced changeset #{rev}" |
82 | end if youngest_stored < youngest_rev |
83 | end # end transaction |
84 | rescue ActiveRecord::RecordInvalid => rie |
85 | # just silently ignore it and log it, we only have this one validation for now |
86 | #logger.error rie |
87 | logger.error "Revision already exists" |
88 | end |
89 | end |
90 | |
91 | end |