HOW-TO:Create add-on PRs using Git Subtree Merging: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
mNo edit summary
 
(11 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{mininav|[[Add-on development]]}}


== Guidelines ==
General [[Add-on rules]] apply. Additional rules when submitting PRs on Github:
* PR should contain one commit only.
* Commit message should have the format "[addonid] version". Example: "[my.cool.addon] 1.0.1"
As with mailing list, only PRs from add-on author will be accepted. Patches should be submitted upstream.
== Example git setup using Subtree merging ==


=== First time setup ===
=== First time setup ===


Clone the XBMC addon repository:
First fork and clone the relevant [[official add-on repository]]. In this example we use the plugins repo:
<pre>
<pre>
git clone [email protected]:xbmc/repo-plugins.git
git clone [email protected]:me/repo-plugins.git
cd repo-plugins
cd repo-plugins
</pre>
</pre>


 
Add the git repository where your addon resides as a remote:
For this example we will use an addon named "myaddon". Add the git repo where you addon resides as a remote:
<pre>
<pre>
git remote add myaddon [email protected]:me/myaddon.git
git remote add myaddon [email protected]:me/myaddon.git
git fetch myaddon
git fetch myaddon
</pre>
</pre>


Create a new branch for the addon:
Create a new branch for the addon:
Line 32: Line 21:
</pre>
</pre>


The current directory should contain the files from the myaddon repository. To switch back to gotham branch of the "repo-plugins" repository:
The current directory should contain the files from the myaddon repository.
 
To switch back to gotham branch of the "repo-plugins" repository:


<pre>
<pre>
git checkout gotham
git checkout gotham
</pre>
</pre>
'''Note:''' gotham is just an example. Choose the branch which is the lowest version you want to support. The plugin is available for that version and later. (Do not submit PR for each version) e.g. For helix and above, submit the PR to helix.


'''Note:''' If your addon already exist in repo, it must first be removed with:
'''Note:''' If your addon already exist in repo, it must first be removed with:
Line 59: Line 52:
</pre>
</pre>


You can now open a PR on Github.
'''Note:''' Remember to send the PR to the correct branch. If you have pushed to gotham branch, you should request pull to the gotham branch in repo.
'''Note:''' If you have multiple plugins, create separate branches e.g. gotham_myplugin from current gotham branch, commit and push to that branch and send a PR from that branch. Else, github sends all commits to the same PR.


=== Updating addon to a new version ===
=== Updating addon to a new version ===
Line 69: Line 67:
git commit -m "[plugin.my.addon] 1.0.2"
git commit -m "[plugin.my.addon] 1.0.2"
git push origin gotham
git push origin gotham
</pre>
* NOTE: Does not work if pull.rebase=true in git config
* NOTE: if using git > 2.9, the second line will need to be
<pre>
git pull --strategy subtree --squash myaddon master --allow-unrelated-histories
</pre>
</pre>




For more info about Subtree Merging see http://git-scm.com/book/en/v1/Git-Tools-Subtree-Merging
For more info about Subtree Merging see http://git-scm.com/book/en/v1/Git-Tools-Subtree-Merging
[[Category:Add-on_development]]

Latest revision as of 09:39, 17 December 2020

Home icon grey.png   ▶ Add-on development ▶ HOW-TO:Create add-on PRs using Git Subtree Merging


First time setup

First fork and clone the relevant official add-on repository. In this example we use the plugins repo:

git clone [email protected]:me/repo-plugins.git
cd repo-plugins

Add the git repository where your addon resides as a remote:

git remote add myaddon [email protected]:me/myaddon.git
git fetch myaddon

Create a new branch for the addon:

git checkout -b myaddon_branch myaddon/master

The current directory should contain the files from the myaddon repository.

To switch back to gotham branch of the "repo-plugins" repository:

git checkout gotham

Note: gotham is just an example. Choose the branch which is the lowest version you want to support. The plugin is available for that version and later. (Do not submit PR for each version) e.g. For helix and above, submit the PR to helix.

Note: If your addon already exist in repo, it must first be removed with:

git rm -r plugin.my.addon/

Now we use subtree merge to pull myaddon into the gotham branch of repo-plugins:

git read-tree --prefix=plugin.my.addon/ -u myaddon_branch

To see the changes that are about to be committed:

git diff --staged

Finally, commit the changes:

git commit -m "[plugin.my.addon] 1.0.1"
git push origin gotham

You can now open a PR on Github.

Note: Remember to send the PR to the correct branch. If you have pushed to gotham branch, you should request pull to the gotham branch in repo.

Note: If you have multiple plugins, create separate branches e.g. gotham_myplugin from current gotham branch, commit and push to that branch and send a PR from that branch. Else, github sends all commits to the same PR.

Updating addon to a new version

Updating the addon is now easy. For this example we pull the master branch from myaddon:

git checkout gotham
git pull --strategy subtree --squash myaddon master
git commit -m "[plugin.my.addon] 1.0.2"
git push origin gotham
  • NOTE: Does not work if pull.rebase=true in git config
  • NOTE: if using git > 2.9, the second line will need to be
git pull --strategy subtree --squash myaddon master --allow-unrelated-histories


For more info about Subtree Merging see http://git-scm.com/book/en/v1/Git-Tools-Subtree-Merging