You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/services/gitea/repository/entries/create_service.rb

44 lines
1.0 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

class Gitea::Repository::Entries::CreateService < Gitea::ClientService
attr_reader :user, :repo_name, :filepath, :body
# ref: The name of the commit/branch/tag. Default the repositorys default branch (usually master)
# filepath: path of the dir, file, symlink or submodule in the repo
# repo_name: the name of repository
# body:
# {
# "author": {
# "email": "user@example.com",
# "name": "string"
# },
# "branch": "string",
# "committer": {
# "email": "user@example.com",
# "name": "string"
# },
# "content": "string", # content must be base64 encoded
# "message": "string",
# "new_branch": "string"
# }
#
def initialize(user, repo_name, filepath, body)
@user = user
@repo_name = repo_name
@filepath = filepath
@body = body
end
def call
post(url, params)
end
private
def params
Hash.new.merge(token: user.gitea_token, data: body)
end
def url
"/repos/#{user.login}/#{repo_name}/contents/#{filepath}".freeze
end
end