How To Add or Update WordPress Plugin SVN Repository with CLI

With lots of dedication & hard work you have created a WP plugin, submitted for review and your plugin got approved by WP plugin directory team. Now you have the SVN repository URL for your plugin with you but you have no idea how to use it. In this article, I’ll tell you how you can submit your new plugin to SVN repository as well as how you can update your existing plugin to a newer version.

Here I’ll show you how to manage plugin repository with SVN CLI (Command Line Interface). There are a few SVN GUI applications available, but we’ll focus into CLI and if you are a developer you should use CLI more than GUI applications for development.

If you are using Windows OS then you can download TortoiseSVN and this is a GUI SVN application, but while installing it has the option to install CLI with it. So after installing this application on Windows, you can follow these steps below and if you are on MacOS then you don’t need to install anything there.

Adding New WP Plugin To SVN Repository

Step 1: Checkout

When you have SVN repo URL with you then you need to download the repo directories to your local directory. This process is called Checkout.

1. Suppose your plugin name is My New Plugin, so now create a local directory for it.

2. Then type the commands below in your Terminal on MacOS & SVN CLI application by Tortoise for Windows.

svn co https://plugins.svn.wordpress.org/YOUR-PLUGIN YOUR-LOCAL-DIRECTORY

After running the command svn directories are downloaded in your local directory and it has 4 directories.

./assets/
./branches/
./tags/
./trunk/

Step 2: Adding The Scripts

3. Now you need to copy your developed plugin scripts to ./trunk/  directory.

4. Then run the commands below

cd YOUR-LOCAL-DIRECTORY
svn add trunk/*

Now all the files & folders within the ./trunk/ directory have added and ready to commit to the svn repo.

Step 3: Commit

5. To commit the plugin scripts type the command below

svn --username=WP-USERNAME ci -m "Adding the first version of my plugin"

Then it will ask for the password of your WordPress profile for which you have provided the username.

After completing this process your plugin added successfully and will be available on the WP plugin directory within a few minutes.

Update Plugin To New Version

Your plugin is available on the plugin directory and users are loving it. Now you want to provide an update of the plugin to the users and to do that again you need to use SVN repo for that. So follow along with me to update and distribute the plugin.

I’m assuming that you still have that svn repo structure available on your local directory. If not, then do the checkout step first mentioned above, then follow commands below.

Step 1: Update

1. Now copy paste all the updated files into ./trunk/  directory and tag previous version and the current version with directories named by version number within ./tags/  directory like below.

./tags/1.0/VERSION1.0 SCRIPTS
./tags/2.0/VERSION2.0 SCRIPTS

2. Then type these commands below in your terminal.

cd YOUR-LOCAL-DIRECTORY
svn up

Step 2: Check Status

3. To check the status of files and folders on svn type the command below.

svn stat
> M trunk/YOUR-PLUGIN/my-plugin.php
> ? trunk/YOUR-PLUGIN/new-file.php

4. Now you can see “M” for those files which are updated and available previously and “?” for those files which were not present previously. So you need to add those files to svn before commit and to add the files you need to follow Adding The Scripts step mentioned before.

5. After adding the files now again check the status and see if you can see any “?” there. If not then follow the command below to commit.

svn --username=WP-USERNAME ci -m "Updating my plugin to newer version"

6. This is the optional step for those who have an issue to commit. This issue normally occurs for those who have multiple contributors for a plugin and if you’re one of the contributors who want to commit to the plugin you can have the issue mentioned below.

svn: E175013: Commit failed (details follow):
svn: E175013: Access to ‘/!svn/me’ forbidden

If you see something similar to this error then it would appear you aren’t added as a committer to the plugins for this account (there’s a difference between a contributor and a committer), only a committer can add code to SVN, this is managed from the plugins Advanced View page, in the right-hand sidebar on the plugin page.

Commiters of a WP plugin

After one is added, there is a delay before the changes take effect, so you won’t have instant access, wait an hour or so after being added as a committer.

Now you can commit to svn to make changes without any issues.

Leave a Reply

Your email address will not be published. Required fields are marked *