Class: TFSGraph::ChangesetMerge

Inherits:
Entity
  • Object
show all
Defined in:
lib/tfs_graph/changeset_merge.rb

Constant Summary collapse

SCHEMA =
{
  target_version: {key: "TargetVersion", type: Integer},
  source_version: {key: "SourceVersion", type: Integer},
  branch: {default: nil, type: String}
}

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Entity

inherited

Class Method Details

.create(attrs) ⇒ Object

overwrite the creator, and create a relationship between the two changesets requested instead of a distinct object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/tfs_graph/changeset_merge.rb', line 17

def self.create(attrs)
  begin
    merge = new(attrs)

    # this will throw an error if one of the relations is not found
    # this is the desired condition as it will throw out the merge if there aren't two endpoints found
    target, source = merge.get_relations

    Related::Relationship.create :merges, target, source

    # relate the branches as well
    Related::Relationship.create :related, source.branch, target.branch

    Related::Relationship.create :included, source.branch, target
    Related::Relationship.create :included, target.branch, source

    merge
  rescue Related::NotFound => ex
    # puts "Could not find a changeset to merge with: #{ex.message}"
  rescue Related::ValidationsFailed => ex
    # puts "Couldn't create relationship for #{merge.source_version} to #{merge.target_version}"
  end
end

Instance Method Details

#get_relationsObject



45
46
47
# File 'lib/tfs_graph/changeset_merge.rb', line 45

def get_relations
  return get_target, get_source
end

#get_sourceObject



49
50
51
# File 'lib/tfs_graph/changeset_merge.rb', line 49

def get_source
  Changeset.find(source_version)
end

#get_targetObject



53
54
55
# File 'lib/tfs_graph/changeset_merge.rb', line 53

def get_target
  Changeset.find(target_version)
end

#saveObject



41
42
43
# File 'lib/tfs_graph/changeset_merge.rb', line 41

def save
  # nothing, no need to save
end