Class: Amp::Git::WorkingDirectoryChangeset
- Inherits:
-
Core::Repositories::AbstractChangeset
- Object
- Core::Repositories::AbstractChangeset
- Amp::Git::WorkingDirectoryChangeset
- Defined in:
- lib/amp-git/repo_format/changeset.rb
Instance Attribute Summary collapse
-
#repo ⇒ Object
(also: #repository)
Returns the value of attribute repo.
Instance Method Summary collapse
-
#added ⇒ Object
What files have we added?.
-
#all_files ⇒ Array<String>
Returns a list of all files that are tracked at this current revision.
-
#altered_files ⇒ Object
What files have been altered in this changeset?.
-
#branch ⇒ String
Which branch this changeset belongs to.
-
#clean ⇒ Object
What files are pristine since the last revision?.
-
#date ⇒ Time
When was the changeset made?.
-
#deleted ⇒ Object
What files have been deleted (but not officially)?.
- #description ⇒ String
-
#each(&b) ⇒ Changeset
Iterates over every tracked file at this point in time.
-
#get_file(filename) ⇒ AbstractVersionedFile
(also: #[])
Retrieve
filename
. -
#initialize(repo, opts = {:text => ''}) ⇒ WorkingDirectoryChangeset
constructor
A new instance of WorkingDirectoryChangeset.
-
#modified ⇒ Object
What files have changed?.
-
#parents ⇒ Array<Abstract Changeset>
the nodes that this node inherits from.
-
#parse! ⇒ Object
yeah, i know, you could combine these all into one for a clean sweep.
-
#removed ⇒ Object
What files have been removed?.
- #revision ⇒ Object
- #status ⇒ Object
-
#unknown ⇒ Object
What files are hanging out, but untracked?.
-
#user ⇒ String
The user who made the changeset.
-
#walk(match, check_ignored = false) ⇒ Array<String>
Recursively walk the directory tree, getting all files that
match
says are good. -
#working? ⇒ Boolean
Is this changeset a working changeset?.
Constructor Details
#initialize(repo, opts = {:text => ''}) ⇒ WorkingDirectoryChangeset
Returns a new instance of WorkingDirectoryChangeset.
208 209 210 211 212 213 214 215 |
# File 'lib/amp-git/repo_format/changeset.rb', line 208 def initialize(repo, opts={:text => ''}) @repo = repo @text = opts[:text] @date = Time.parse opts[:date].to_s @user = opts[:user] @parents = opts[:parents].map {|p| Changeset.new(@repo, p) } if opts[:parents] @status = opts[:changes] end |
Instance Attribute Details
#repo ⇒ Object Also known as: repository
Returns the value of attribute repo.
205 206 207 |
# File 'lib/amp-git/repo_format/changeset.rb', line 205 def repo @repo end |
Instance Method Details
#added ⇒ Object
What files have we added?
311 |
# File 'lib/amp-git/repo_format/changeset.rb', line 311 def added; status[:added]; end |
#all_files ⇒ Array<String>
Returns a list of all files that are tracked at this current revision.
283 284 285 |
# File 'lib/amp-git/repo_format/changeset.rb', line 283 def all_files @all_files ||= `git ls-files 2> /dev/null`.split("\n") end |
#altered_files ⇒ Object
What files have been altered in this changeset?
307 |
# File 'lib/amp-git/repo_format/changeset.rb', line 307 def altered_files; `git show --name-only #{node} 2> /dev/null`.split("\n"); end |
#branch ⇒ String
Which branch this changeset belongs to
256 257 258 |
# File 'lib/amp-git/repo_format/changeset.rb', line 256 def branch @branch ||= `git branch 2> /dev/null`[/\*\s(.+)$/, 1] end |
#clean ⇒ Object
What files are pristine since the last revision?
319 |
# File 'lib/amp-git/repo_format/changeset.rb', line 319 def clean; status[:normal]; end |
#date ⇒ Time
When was the changeset made?
240 241 242 |
# File 'lib/amp-git/repo_format/changeset.rb', line 240 def date Time.now end |
#deleted ⇒ Object
What files have been deleted (but not officially)?
315 |
# File 'lib/amp-git/repo_format/changeset.rb', line 315 def deleted; status[:deleted]; end |
#description ⇒ String
262 263 264 |
# File 'lib/amp-git/repo_format/changeset.rb', line 262 def description @text || '' end |
#each(&b) ⇒ Changeset
Iterates over every tracked file at this point in time.
274 275 276 277 |
# File 'lib/amp-git/repo_format/changeset.rb', line 274 def each(&b) all_files.each( &b) self end |
#get_file(filename) ⇒ AbstractVersionedFile Also known as: []
Retrieve filename
231 232 233 |
# File 'lib/amp-git/repo_format/changeset.rb', line 231 def get_file(filename) VersionedWorkingFile.new @repo, filename end |
#modified ⇒ Object
What files have changed?
309 |
# File 'lib/amp-git/repo_format/changeset.rb', line 309 def modified; status[:modified]; end |
#parents ⇒ Array<Abstract Changeset>
the nodes that this node inherits from
221 222 223 |
# File 'lib/amp-git/repo_format/changeset.rb', line 221 def parents @parents || (parse! && @parents) end |
#parse! ⇒ Object
yeah, i know, you could combine these all into one for a clean sweep. but it’s clearer this way
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
# File 'lib/amp-git/repo_format/changeset.rb', line 323 def parse! return if @parsed log_data = `git log -1 HEAD 2> /dev/null` unless log_data.empty? # DETERMINING PARENTS commit = log_data[/^commit (.+)$/, 1] dad = commit ? commit[0..6] : nil mom = nil if log_data =~ /^Merge: (.+)\.\.\. (.+)\.\.\.$/ # Merge: 1c002dd... 35cfb2b... dad = $1 # just have them both use the short name, nbd mom = $2 end @parents = [dad, mom].compact.map {|p| Changeset.new @repo, p } else @parents = [] end @parsed = true end |
#removed ⇒ Object
What files have been removed?
313 |
# File 'lib/amp-git/repo_format/changeset.rb', line 313 def removed; status[:removed]; end |
#revision ⇒ Object
225 |
# File 'lib/amp-git/repo_format/changeset.rb', line 225 def revision; nil; end |
#status ⇒ Object
266 267 268 |
# File 'lib/amp-git/repo_format/changeset.rb', line 266 def status @status ||= @repo.status :unknown => true end |
#unknown ⇒ Object
What files are hanging out, but untracked?
317 |
# File 'lib/amp-git/repo_format/changeset.rb', line 317 def unknown; status[:unknown]; end |
#user ⇒ String
The user who made the changeset
248 249 250 |
# File 'lib/amp-git/repo_format/changeset.rb', line 248 def user @user ||= @repo.config.username end |
#walk(match, check_ignored = false) ⇒ Array<String>
Recursively walk the directory tree, getting all files that match
says are good.
301 302 303 304 |
# File 'lib/amp-git/repo_format/changeset.rb', line 301 def walk(match, check_ignored = false) tree = @repo.staging_area.walk true, check_ignored, match tree.keys.sort end |
#working? ⇒ Boolean
Is this changeset a working changeset?
290 291 292 |
# File 'lib/amp-git/repo_format/changeset.rb', line 290 def working? true end |