Class: Repository::Git
- Inherits:
-
- Object
- ActiveRecord::Base
- Repository::Git
- Defined in:
- app/models/repository/git.rb
Class Method Summary
Instance Method Summary
- - (Object) branches
-
- (Object) fetch_changesets
With SCM’s that have a sequential commit numbering, redmine is able to be clever and only fetch changesets going forward from the most recent one it knows about.
- - (Object) latest_changesets(path, rev, limit = 10)
- - (Object) scm_adapter
- - (Object) tags
Methods inherited from
available_scm, #cat, #committer_ids=, #committers, #default_branch, #diff, #entries, #entry, factory, fetch_changesets, #find_changeset_by_name, #find_committer_user, #latest_changeset, #properties, #relative_path, #root_url=, scan_changesets_for_issue_ids, #scan_changesets_for_issue_ids, #scm, #scm_name, #supports_annotate?, #supports_cat?, #url=
Methods inherited from ActiveRecord::Base
Class Method Details
+ (Object) scm_name
28 29 30 |
# File 'app/models/repository/git.rb', line 28 def self.scm_name 'Git' end |
Instance Method Details
- (Object) branches
32 33 34 |
# File 'app/models/repository/git.rb', line 32 def branches scm.branches end |
- (Object) fetch_changesets
With SCM’s that have a sequential commit numbering, redmine is able to be clever and only fetch changesets going forward from the most recent one it knows about. However, with git, you never know if people have merged commits into the middle of the repository history, so we should parse the entire log. Since it’s way too slow for large repositories, we only parse 1 week before the last known commit. The repository can still be fully reloaded by calling #clear_changesets before fetching changesets (eg. for offline resync)
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/models/repository/git.rb', line 48 def fetch_changesets c = changesets.find(:first, :order => 'committed_on DESC') since = (c ? c.committed_on - 7.days : nil) revisions = scm.revisions('', nil, nil, :all => true, :since => since) return if revisions.nil? || revisions.empty? recent_changesets = changesets.find(:all, :conditions => ['committed_on >= ?', since]) # Clean out revisions that are no longer in git recent_changesets.each {|c| c.destroy unless revisions.detect {|r| r.scmid.to_s == c.scmid.to_s }} # Subtract revisions that redmine already knows about recent_revisions = recent_changesets.map{|c| c.scmid} revisions.reject!{|r| recent_revisions.include?(r.scmid)} # Save the remaining ones to the database revisions.each{|r| r.save(self)} unless revisions.nil? end |
- (Object) latest_changesets(path, rev, limit = 10)
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/models/repository/git.rb', line 68 def latest_changesets(path,rev,limit=10) revisions = scm.revisions(path, nil, rev, :limit => limit, :all => false) return [] if revisions.nil? || revisions.empty? changesets.find( :all, :conditions => [ "scmid IN (?)", revisions.map!{|c| c.scmid} ], :order => 'committed_on DESC' ) end |
- (Object) scm_adapter
24 25 26 |
# File 'app/models/repository/git.rb', line 24 def scm_adapter Redmine::Scm::Adapters::GitAdapter end |
- (Object) tags
36 37 38 |
# File 'app/models/repository/git.rb', line 36 def scm. end |