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}
}

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Entity

inherited, #initialize, #schema, #to_hash

Constructor Details

This class inherits a constructor from TFSGraph::Entity

Class Method Details

.create(attrs) ⇒ Object

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



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

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

    target, source = merge.get_relations
    return nil unless target.persisted? and source.persisted?

    merge.join :merges, target, source

    # relate the branches as well
    if source.branch && target.branch
      merge.join :related, source.branch, target.branch

      merge.join :included, source.branch, target
      merge.join :included, target.branch, source
    end

    merge
  rescue TFSGraph::Repository::NotFound => ex
    # puts "Could not find a changeset to merge with: #{ex.message}"
  end
end

Instance Method Details

#get_relationsObject



38
39
40
# File 'lib/tfs_graph/changeset_merge.rb', line 38

def get_relations
  return get_target, get_source
end

#get_sourceObject



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

def get_source
  repo.find(source_version)
end

#get_targetObject



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

def get_target
  repo.find(target_version)
end

#join(relation, target, source) ⇒ Object



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

def join(relation, target, source)
  repo.relate(relation, target.db_object, source.db_object)
end