These API methods let you retrieve the contents of files within a repository as Base64 encoded content.
%w[ path message content ]Github::Constants::ACCEPT,Github::Constants::ACCEPTED_OAUTH_SCOPES,Github::Constants::ACCEPT_CHARSET,Github::Constants::CACHE_CONTROL,Github::Constants::CONTENT_LENGTH,Github::Constants::CONTENT_TYPE,Github::Constants::DATE,Github::Constants::ETAG,Github::Constants::HEADER_LAST,Github::Constants::HEADER_LINK,Github::Constants::HEADER_NEXT,Github::Constants::LOCATION,Github::Constants::META_FIRST,Github::Constants::META_LAST,Github::Constants::META_NEXT,Github::Constants::META_PREV,Github::Constants::META_REL,Github::Constants::OAUTH_SCOPES,Github::Constants::PARAM_PAGE,Github::Constants::PARAM_PER_PAGE,Github::Constants::PARAM_START_PAGE,Github::Constants::RATELIMIT_LIMIT,Github::Constants::RATELIMIT_REMAINING,Github::Constants::RATELIMIT_RESET,Github::Constants::SERVER,Github::Constants::USER_AGENT
Get archive link.
Create a file.
Delete a file.
Get contents.
Get the LICENSE.
Get the README.
Update a file.
after_callbacks,after_request,#api_methods_in,#arguments,before_callbacks,before_request,clear_request_methods!,#disable_redirects,#execute,extend_with_actions,extra_methods,#extract_basic_auth,extract_class_name,#filter_callbacks,inherited,#initialize,internal_methods,method_added,#method_missing,#module_methods_in,namespace,request_methods,require_all,#respond_to?,root!,#run_callbacks,#set,#yield_or_eval
#delete_request,#get_request,#head_request,#options_request,#patch_request,#post_request,#put_request
#ratelimit,#ratelimit_remaining,#ratelimit_reset
#auth_code,#authenticated?,#authentication,#authorize_url,#basic_authed?,#client,#get_token
This class inherits a constructor fromGithub::API
This class handles dynamic methods through themethod_missing method in the classGithub::API
For private repositories, these links are temporary and expire quickly.
Get archive link
This method will return a 302 to a URL to download a tarball or zipball archive for a repository. Please make sure your HTTP framework is configured to follow redirects or you will need to use the Location header to make a second GET request.
github=Github.newgithub.repos.contents.archive'user-name','repo-name',archive_format:"tarball",ref:"master"Parameters:
251252253254255256257258259260261 | # File 'lib/github_api/client/repos/contents.rb', line 251defarchive(*args)arguments(args,required:[:user,:repo])params=arguments.paramsarchive_format=params.delete('archive_format')||'tarball'ref=params.delete('ref')||'master'disable_redirectsdoresponse=get_request("/repos/#{arguments.user}/#{arguments.repo}/#{archive_format}/#{ref}",params)response.headers.locationendend |
Create a file
This method creates a new file in a repository
Optional Parameters
The :author section is optional and is filled in with the :committer information if omitted. If the :committer information is omitted, the authenticated user’s information is used.
You must provide values for both :name and :email, whether you choose to use :author or :committer. Otherwise, you’ll receive a 500 status code.
Both the author and commiter parameters have the same keys:
github=Github.newgithub.repos.contents.create'user-name','repo-name','path',path:'hello.rb',content:"puts 'hello ruby'",message:"my commit message"Parameters:
121122123124125126127128129 | # File 'lib/github_api/client/repos/contents.rb', line 121defcreate(*args)arguments(args,required:[:user,:repo,:path])doassert_requiredREQUIRED_CONTENT_OPTIONSendparams=arguments.paramsparams.strict_encode64('content')put_request("/repos/#{arguments.user}/#{arguments.repo}/contents/#{arguments.path}",params)end |
Delete a file
This method deletes a file in a repository
Optional Parameters
The :author section is optional and is filled in with the :committer information if omitted. If the :committer information is omitted, the authenticated user’s information is used.
You must provide values for both :name and :email, whether you choose to use :author or :committer. Otherwise, you’ll receive a 500 status code.
Both the author and commiter parameters have the same keys:
github=Github.newgithub.repos.contents.delete'user-name','repo-name','path',path:'hello.rb',message:"delete hello.rb file",sha:"329688480d39049927147c162b9d2deaf885005f"Parameters:
219220221222223224225 | # File 'lib/github_api/client/repos/contents.rb', line 219defdelete(*args)arguments(args,required:[:user,:repo,:path])doassert_required%w[ path message sha ]enddelete_request("/repos/#{arguments.user}/#{arguments.repo}/contents/#{arguments.path}",arguments.params)end |
Get contents
This method returns the contents of any file or directory in a repository.
github=Github.newgithub.repos.contents.get'user-name','repo-name','path'github=Github.newuser:'user-name',repo:'repo-name'github.repos.contents.getpath:'README.md'Parameters:
7374757677 | # File 'lib/github_api/client/repos/contents.rb', line 73defget(*args)arguments(args,required:[:user,:repo,:path])get_request("/repos/#{arguments.user}/#{arguments.repo}/contents/#{arguments.path}",arguments.params)end |
Get the LICENSE
This method returns the contents of the repository’s license file, if one is detected.
github=Github.newgithub.repos.contents.license'user-name','repo-name'Parameters:
4748495051 | # File 'lib/github_api/client/repos/contents.rb', line 47deflicense(*args)arguments(args,required:[:user,:repo])get_request("/repos/#{arguments.user}/#{arguments.repo}/license",arguments.params)end |
Get the README
This method returns the preferred README for a repository.
github=Github.newgithub.repos.contents.readme'user-name','repo-name'content=Github::Client::Repos::Contents.newuser:'user-name',repo:'repo-name'content.readmeParameters:
3031323334 | # File 'lib/github_api/client/repos/contents.rb', line 30defreadme(*args)arguments(args,required:[:user,:repo])get_request("/repos/#{arguments.user}/#{arguments.repo}/readme",arguments.params)end |
Update a file
This method updates a file in a repository
Optional Parameters
The :author section is optional and is filled in with the :committer information if omitted. If the :committer information is omitted, the authenticated user’s information is used.
You must provide values for both :name and :email, whether you choose to use :author or :committer. Otherwise, you’ll receive a 500 status code.
Both the author and commiter parameters have the same keys:
github=Github.newgithub.repos.contents.update'user-name','repo-name','path',path:'hello.rb',content:"puts 'hello ruby again'",message:"my commit message",sha:"25b0bef9e404bd2e3233de26b7ef8cbd86d0e913"Parameters:
175176177 | # File 'lib/github_api/client/repos/contents.rb', line 175defupdate(*args)create(*args)end |