Class: Amp::Git::Changeset

Inherits:
Core::Repositories::AbstractChangeset
  • Object
show all
Defined in:
lib/amp-git/repo_format/changeset.rb

Overview

A Changeset is a simple way of accessing the repository within a certain revision. For example, if the user specifies revision # 36, or revision 3adf21, then we can look those up, and work within the repository at the moment of that revision.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo, short_name) ⇒ Changeset

Returns a new instance of Changeset.



31
32
33
34
35
36
37
38
39
40
# File 'lib/amp-git/repo_format/changeset.rb', line 31

def initialize(repo, short_name)
  @repo       = repo
  if short_name.kind_of?(Integer)
    @revision = short_name
    @node_id = convert_rev_to_node(short_name)
  else
    @revision = convert_node_to_rev(short_name)
    @node_id = short_name
  end
end

Instance Attribute Details

#repoObject Also known as: repository

Returns the value of attribute repo.



27
28
29
# File 'lib/amp-git/repo_format/changeset.rb', line 27

def repo
  @repo
end

#revisionObject (readonly)

Returns the value of attribute revision.



28
29
30
# File 'lib/amp-git/repo_format/changeset.rb', line 28

def revision
  @revision
end

Instance Method Details

#<=>(other) ⇒ Integer

Compares 2 changesets so we can sort them and whatnot

Parameters:

  • other (Changeset)

    a changeset we will compare against

Returns:

  • (Integer)

    -1, 0, or 1. Typical comparison.



50
51
52
# File 'lib/amp-git/repo_format/changeset.rb', line 50

def <=>(other)
  date <=> other.date
end

#all_filesArray<String>

Returns a list of all files that are tracked at this current revision.

Returns:

  • (Array<String>)

    the files tracked at the given revision



128
129
130
131
# File 'lib/amp-git/repo_format/changeset.rb', line 128

def all_files
  parse!
  @all_files
end

#altered_filesArray<String>

What files have been altered in this changeset?

Returns:

  • (Array<String>)


119
120
121
122
# File 'lib/amp-git/repo_format/changeset.rb', line 119

def altered_files
  parse!
  @altered_files
end

#branchString

Which branch this changeset belongs to

Returns:

  • (String)

    the user who made the changeset

Raises:

  • (NotImplementedError)


103
104
105
106
# File 'lib/amp-git/repo_format/changeset.rb', line 103

def branch
  parse!
  raise NotImplementedError.new("branch() must be implemented by subclasses of AbstractChangeset.")
end

#dateTime

When was the changeset made?

Returns:

  • (Time)


85
86
87
88
# File 'lib/amp-git/repo_format/changeset.rb', line 85

def date
  parse!
  @date
end

#descriptionString

Returns:

  • (String)


110
111
112
113
# File 'lib/amp-git/repo_format/changeset.rb', line 110

def description
  parse!
  @description
end

#each(&b) ⇒ Changeset

Iterates over every tracked file at this point in time.

Returns:

  • (Changeset)

    self, because that’s how #each works



58
59
60
61
# File 'lib/amp-git/repo_format/changeset.rb', line 58

def each(&b)
  all_files.each( &b)
  self
end

#get_file(filename) ⇒ AbstractVersionedFile Also known as: []

Retrieve filename

Returns:

  • (AbstractVersionedFile)


76
77
78
# File 'lib/amp-git/repo_format/changeset.rb', line 76

def get_file(filename)
  VersionedFile.new @repo, file, :revision => node
end

#nodeObject



42
# File 'lib/amp-git/repo_format/changeset.rb', line 42

def node; @node_id; end

#parentsArray<Abstract Changeset>

the nodes that this node inherits from

Returns:



67
68
69
70
# File 'lib/amp-git/repo_format/changeset.rb', line 67

def parents
  parse!
  @parents
end

#userString

The user who made the changeset

Returns:

  • (String)

    the user who made the changeset



94
95
96
97
# File 'lib/amp-git/repo_format/changeset.rb', line 94

def user
  parse!
  @user
end

#working?Boolean

Is this changeset a working changeset?

Returns:

  • (Boolean)

    is the changeset representing the working directory?



136
137
138
# File 'lib/amp-git/repo_format/changeset.rb', line 136

def working?
  false
end