Class: Repository::Git
Constant Summary
collapse
- ATTRIBUTE_KEY_NAMES =
{
"url" => "Path to repository",
}
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Repository
available_scm, #cat, #committer_ids=, #committers, #default_branch, #diff, #diff_format_revisions, #entries, #entry, factory, fetch_changesets, #find_committer_user, #latest_changeset, #password, #password=, #properties, #relative_path, #root_url=, scan_changesets_for_issue_ids, #scan_changesets_for_issue_ids, #scm, #scm_adapter, scm_available, scm_command, #scm_name, scm_version_string, #supports_all_revisions?, #supports_annotate?, #supports_cat?, #url=
cipher_key, decrypt_text, encrypt_text, included
Class Method Details
.changeset_identifier(changeset) ⇒ Object
Returns the identifier for the given git changeset
48
49
50
|
# File 'app/models/repository/git.rb', line 48
def self.changeset_identifier(changeset)
changeset.scmid
end
|
Returns the readable identifier for the given git changeset
53
54
55
|
# File 'app/models/repository/git.rb', line 53
def self.format_changeset_identifier(changeset)
changeset.revision[0, 8]
end
|
.human_attribute_name(attribute_key_name) ⇒ Object
27
28
29
|
# File 'app/models/repository/git.rb', line 27
def self.human_attribute_name(attribute_key_name)
ATTRIBUTE_KEY_NAMES[attribute_key_name] || super
end
|
.scm_adapter_class ⇒ Object
.scm_name ⇒ Object
35
36
37
|
# File 'app/models/repository/git.rb', line 35
def self.scm_name
'Git'
end
|
Instance Method Details
#branches ⇒ Object
57
58
59
|
# File 'app/models/repository/git.rb', line 57
def branches
scm.branches
end
|
#fetch_changesets ⇒ Object
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)
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# File 'app/models/repository/git.rb', line 80
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, :reverse => true})
return if revisions.nil? || revisions.empty?
recent_changesets = changesets.find(:all, :conditions => ['committed_on >= ?', since])
recent_changesets.each {|c| c.destroy unless revisions.detect {|r| r.scmid.to_s == c.scmid.to_s }}
recent_revisions = recent_changesets.map{|c| c.scmid}
revisions.reject!{|r| recent_revisions.include?(r.scmid)}
unless revisions.nil?
revisions.each do |rev|
transaction do
changeset = Changeset.new(
:repository => self,
:revision => rev.identifier,
:scmid => rev.scmid,
:committer => rev.author,
:committed_on => rev.time,
:comments => rev.message)
if changeset.save
rev.paths.each do |file|
Change.create(
:changeset => changeset,
:action => file[:action],
:path => file[:path])
end
end
end
end
end
end
|
#find_changeset_by_name(name) ⇒ Object
65
66
67
68
69
70
|
# File 'app/models/repository/git.rb', line 65
def find_changeset_by_name(name)
return nil if name.nil? || name.empty?
e = changesets.find(:first, :conditions => ['revision = ?', name.to_s])
return e if e
changesets.find(:first, :conditions => ['scmid LIKE ?', "#{name}%"])
end
|
#latest_changesets(path, rev, limit = 10) ⇒ Object
121
122
123
124
125
126
127
128
129
130
131
132
133
|
# File 'app/models/repository/git.rb', line 121
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
|
#repo_log_encoding ⇒ Object
43
44
45
|
# File 'app/models/repository/git.rb', line 43
def repo_log_encoding
'UTF-8'
end
|
#supports_directory_revisions? ⇒ Boolean
39
40
41
|
# File 'app/models/repository/git.rb', line 39
def supports_directory_revisions?
true
end
|
61
62
63
|
# File 'app/models/repository/git.rb', line 61
def tags
scm.tags
end
|