Module: Gitlab::DataBuilder::Repository

Extended by:
Repository
Included in:
Repository
Defined in:
lib/gitlab/data_builder/repository.rb

Constant Summary collapse

SAMPLE_DATA =
{
  event_name: 'repository_update',
  user_id: 10,
  user_name: 'john.doe',
  user_email: '[email protected]',
  user_avatar: 'http://example.com/avatar/user.png',
  project_id: 40,
  changes: [
    {
      before: "8205ea8d81ce0c6b90fbe8280d118cc9fdad6130",
      after: "4045ea7a3df38697b3730a20fb73c8bed8a3e69e",
      ref: "refs/heads/master"
    }
  ],
  "refs": ["refs/heads/master"]
}.freeze

Instance Method Summary collapse

Instance Method Details

#sample_dataObject


53
54
55
# File 'lib/gitlab/data_builder/repository.rb', line 53

def sample_data
  SAMPLE_DATA
end

#single_change(oldrev, newrev, ref) ⇒ Object

Produce a hash of partial data for a single change


45
46
47
48
49
50
51
# File 'lib/gitlab/data_builder/repository.rb', line 45

def single_change(oldrev, newrev, ref)
  {
    before: oldrev,
    after: newrev,
    ref: ref
  }
end

#update(project, user, changes, refs) ⇒ Object

Produce a hash of post-receive data


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/gitlab/data_builder/repository.rb', line 26

def update(project, user, changes, refs)
  {
    event_name: 'repository_update',

    user_id: user.id,
    user_name: user.name,
    user_email: user.email,
    user_avatar: user.avatar_url,

    project_id: project.id,
    project: project.hook_attrs,

    changes: changes,

    refs: refs
  }
end