1 <?php
2 /**
3 * @package Joomla.Platform
4 * @subpackage GitHub
5 *
6 * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE
8 */
9
10 defined('JPATH_PLATFORM') or die;
11
12 /**
13 * GitHub API Data Tags class for the Joomla Platform.
14 *
15 * This tags API only deals with tag objects - so only annotated tags, not lightweight tags.
16 *
17 * @documentation https://developer.github.com/v3/git/tags/
18 *
19 * @since 11.3
20 * @deprecated 4.0 Use the `joomla/github` package via Composer instead
21 */
22 class JGithubPackageDataTags extends JGithubPackage
23 {
24 /**
25 * Get a Tag.
26 *
27 * @param string $owner The name of the owner of the GitHub repository.
28 * @param string $repo The name of the GitHub repository.
29 * @param string $sha The SHA1 value to set the reference to.
30 *
31 * @since 3.3 (CMS)
32 *
33 * @return object
34 */
35 public function get($owner, $repo, $sha)
36 {
37 // Build the request path.
38 $path = '/repos/' . $owner . '/' . $repo . '/git/tags/' . $sha;
39
40 return $this->processResponse(
41 $this->client->get($this->fetchUrl($path))
42 );
43 }
44
45 /**
46 * Create a Tag Object
47 *
48 * Note that creating a tag object does not create the reference that makes a tag in Git.
49 * If you want to create an annotated tag in Git, you have to do this call to create the tag object,
50 * and then create the refs/tags/[tag] reference. If you want to create a lightweight tag,
51 * you simply have to create the reference - this call would be unnecessary.
52 *
53 * @param string $owner The name of the owner of the GitHub repository.
54 * @param string $repo The name of the GitHub repository.
55 * @param string $tag The tag string.
56 * @param string $message The tag message.
57 * @param string $object The SHA of the git object this is tagging.
58 * @param string $type The type of the object we’re tagging. Normally this is a commit
59 * but it can also be a tree or a blob.
60 * @param string $tagger_name The name of the author of the tag.
61 * @param string $tagger_email The email of the author of the tag.
62 * @param string $tagger_date Timestamp of when this object was tagged.
63 *
64 * @since 3.3 (CMS)
65 *
66 * @return object
67 */
68 public function create($owner, $repo, $tag, $message, $object, $type, $tagger_name, $tagger_email, $tagger_date)
69 {
70 // Build the request path.
71 $path = '/repos/' . $owner . '/' . $repo . '/git/tags';
72
73 $data = array(
74 'tag' => $tag,
75 'message' => $message,
76 'object' => $object,
77 'type' => $type,
78 'tagger_name' => $tagger_name,
79 'tagger_email' => $tagger_email,
80 'tagger_date' => $tagger_date,
81 );
82
83 return $this->processResponse(
84 $this->client->post($this->fetchUrl($path), json_encode($data)),
85 201
86 );
87 }
88 }
89