Class: SupportOps::GitLab::RepositorySubmodules

Inherits:
Base
  • Object
show all
Defined in:
lib/support_ops_gitlab/gitlab/repository_submodules.rb

Overview

TODO:

Document attribute meaning

Defines the class RepositorySubmodules within the module SupportOps::GitLab.

Author:

  • Jason Colyer

Since:

  • 1.0.0

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Base

#activate!, #approve!, attributes, #badges, #ban!, #block!, client, #client=, #commits, configure, #contributors, #create_support_pin!, #deactivate!, define_attributes, #delete!, #diffs, #disable_2fa!, #discussions, #emails, #encoded_path, #events, #find, #find!, #gpg_keys, #hard_delete!, #impersonations, #initialize, #issues, #jobs, #latest_pipeline, #members, #memberships, #merge_requests, #move!, #notes, #paid?, #pats, #pipeline_variables, #pipelines, #preferences, #projects, readonly_attributes, #reject!, #revoke!, #rotate!, #save!, #ssh_keys, #store_original_attributes, #subscribe!, #support_pin, to_hash, #tokens, #unban!, #unblock!, #unsubscribe!, #webhooks

Constructor Details

This class inherits a constructor from SupportOps::GitLab::Base

Instance Attribute Details

#author_emailString

Returns the current value of author_email.

Returns:

  • (String)

    the current value of author_email



26
27
28
# File 'lib/support_ops_gitlab/gitlab/repository_submodules.rb', line 26

def author_email
  @author_email
end

#author_nameString

Returns the current value of author_name.

Returns:

  • (String)

    the current value of author_name



26
27
28
# File 'lib/support_ops_gitlab/gitlab/repository_submodules.rb', line 26

def author_name
  @author_name
end

#authored_dateString

Returns the current value of authored_date.

Returns:

  • (String)

    the current value of authored_date



26
27
28
# File 'lib/support_ops_gitlab/gitlab/repository_submodules.rb', line 26

def authored_date
  @authored_date
end

#committed_dateString

Returns the current value of committed_date.

Returns:

  • (String)

    the current value of committed_date



26
27
28
# File 'lib/support_ops_gitlab/gitlab/repository_submodules.rb', line 26

def committed_date
  @committed_date
end

#committer_emailString

Returns the current value of committer_email.

Returns:

  • (String)

    the current value of committer_email



26
27
28
# File 'lib/support_ops_gitlab/gitlab/repository_submodules.rb', line 26

def committer_email
  @committer_email
end

#committer_nameString

Returns the current value of committer_name.

Returns:

  • (String)

    the current value of committer_name



26
27
28
# File 'lib/support_ops_gitlab/gitlab/repository_submodules.rb', line 26

def committer_name
  @committer_name
end

#created_atString

Returns the current value of created_at.

Returns:

  • (String)

    the current value of created_at



26
27
28
# File 'lib/support_ops_gitlab/gitlab/repository_submodules.rb', line 26

def created_at
  @created_at
end

#idString

Returns the current value of id.

Returns:

  • (String)

    the current value of id



26
27
28
# File 'lib/support_ops_gitlab/gitlab/repository_submodules.rb', line 26

def id
  @id
end

#messageString

Returns the current value of message.

Returns:

  • (String)

    the current value of message



26
27
28
# File 'lib/support_ops_gitlab/gitlab/repository_submodules.rb', line 26

def message
  @message
end

#parent_idsArray

Returns the current value of parent_ids.

Returns:

  • (Array)

    the current value of parent_ids



26
27
28
# File 'lib/support_ops_gitlab/gitlab/repository_submodules.rb', line 26

def parent_ids
  @parent_ids
end

#short_idString

Returns the current value of short_id.

Returns:

  • (String)

    the current value of short_id



26
27
28
# File 'lib/support_ops_gitlab/gitlab/repository_submodules.rb', line 26

def short_id
  @short_id
end

#statusString

Returns the current value of status.

Returns:

  • (String)

    the current value of status



26
27
28
# File 'lib/support_ops_gitlab/gitlab/repository_submodules.rb', line 26

def status
  @status
end

#titleString

Returns the current value of title.

Returns:

  • (String)

    the current value of title



26
27
28
# File 'lib/support_ops_gitlab/gitlab/repository_submodules.rb', line 26

def title
  @title
end

Class Method Details

.update!(project_id, path, branch, sha, message = nil) ⇒ Object

Update existing submodule reference in repository

Examples:

require 'support_ops_gitlab'

SupportOps::GitLab::Configuration.configure do |config|
  config.url = 'https://gitlab.com/api/v4'
  config.token = 'abc123'
end

submodule = SupportOps::GitLab::RepositorySubmodules.update!(5, 'lib/modules/example', 'main', '3ddec28ea23acc5caa5d8331a6ecb2a65fc03e88', 'Update submodule reference')
pp submodule.id
# => "ed899a2f4b50b4370feeea94676502b42383c746"

Parameters:

  • project_id (Integer)

    The ID of the project the submodule is in

  • path (String)

    The path to the submodule in the project

  • branch (String)

    The branch to update the submodule in

  • sha (String)

    The commit SHA to use for the update

  • message (String optional) (defaults to: nil)

    The commit message to use (defaults to nil, where it would be ignored)

Returns:

  • String

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.0



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/support_ops_gitlab/gitlab/repository_submodules.rb', line 62

def self.update!(project_id, path, branch, sha, message = nil)
  data = {
    branch: branch,
    commit_sha: sha
  }
  data[:commit_message] = message unless message.nil?
  response = client.conneciton.put("projects/#{project_id}/repository/submodules/#{ERB::Util.url_encode(path)}", data.to_json)
  body = Oj.load(response.body)
  raise "Failed to update submodule #{path} => #{body}" unless response.status == 200
  RepositorySubmodules.new(body)
end