WordPress.orgにプラグインを登録する際のsubversionの使い方

WordPress.orgにプラグインを登録する際のsubversionの使い方


subversion

WordPress公式にプラグインを登録する時、subversionがよくわからなくて、手間取ってしまったため、メモを残しておこうと思います。

最初、SourceTreeを使ってやろうとしてみたのですが、使い方に慣れていない事もあり、結局ターミナルから直接操作した方が、結果的に早かったです。

↑ ↑ ↑ このページの通りにすればいいだけなんですが、用語が少し特殊ですし、英語を一行ずつ読んで理解していくのに時間がかかってしまいました。
なので、このページを翻訳しつつ、私なりのコメントを入れていこうと思います。
訳はかなり適当なので、間違いを見つけた方は、どうぞご指摘ください。

How to Use Subversion サブバージョンの使い方

We’ll describe here some of the basics about using subversion: starting out, changing things, and tagging releases. For more comprehensive documentation, see The SVN Book.

サブバージョンの基本的な使い方について説明します:はじめ方、変更方法、タグのつけ方、などについて。
詳しくは、SVNの本を参照してください。

First, some terminology
If you’re new to subversion, you’ll need to know what a few words mean, so let’s go over how subversion behaves to introduce some terms.

まず、用語について。
サブバージョンを使うのが初めての方は、いくつかの単語の意味を知っておく必要があります。
サブバージョンがどんな風に動くのかを見て行きましょう。

All your files will be centrally stored in the repository on our servers. From that repository, anyone can check out a copy of your plugin files onto their local machine, but, as a plugin author, only you have tho authority to check in. That means you can make changes to the files, add new files, and delete files on your local machine and upload those changes back to the central server. It’s this process of checking in that updates both the files in the repository and also the information displayed in the WordPress.org plugin directory.

あなたのファイルは我々のサーバーにあるリポジトリに確実に保存されます。そのリポジトリから、誰でも、あなたの作ったプラグインをコピーして自分のローカル上に持ち出す(Check out)ことができます。ただし、あなたはプラグイン作者として、チェックイン(check in)する権限があります。ということは、あなたはローカル環境でファイルを変更したり、新しいファイルを追加・削除して、中央サーバーにアップロードすることができる、ということです。このアップデートの過程で、リポジトリのファイルだけでなく、WordPress.orgのプラグインディレクトリにおいても、情報が表示されます。

Subversion keeps track of all these changes so that you can go back and look at old versions or revisions later if you ever need to. In addition to remembering each individual revision, you can tell subversion to tag certain revisions of the repository for easy reference. Tags are great for labelling different releases of your plugin.

サブバージョンはすべての変更過程を保存します。ですので、後で必要になった時にはいつでも、データを元に戻すことができるし、以前のバージョンに戻ったり、見てみることが可能になります。個別のリビジョンに戻るだけでなく、リビジョンにタグをつけておくことで簡単に参照することができます。いろいろなリリースをするときに、タグをつけておくと便利です。

Words are great, but how do I actually use the darn thing?
Let’s describe a few basic tasks you might want to accomplish.

すごいですね、でも実際どうやって使うのでしょうか?
それでは、基本的な方法を説明しましょう。

Task 1 (タスクその1)

Starting from scratch with your brand new plugin repository
All you want to do is add the plugin files you already have to your new repository.

新しいプラグインリポジトリで、ゼロから始めます。
あなたのプラグインファイルを新規リポジトリに追加します。

To do that you’ll need to

そのためには、以下が必要です。

Check out the blank repository.
Add your files to the trunk/ directory of your local copy of the repository.
Check in those files back to the central repository.

空のリポジトリを取り出して(Check out)してください。
ファイルをトランクに追加します。トランクは、ローカルリポジトリにあるディレクトリです。
ファイル群をリモートリポジトリに入れます(Check in)。

直訳だけでは、わかりにくいと思うので、ここで私の独自の説明を入れます。

*wordpress.orgの審査が通った時点で、リモートリポジトリには、すでに空のディレクトリがいくつか作成されているはずです。
*それらをまず、自分のローカルに持ってこなければなりません。
*ローカルに持って来ることをチェックアウトと言います。
*無事にチェックアウトできたら、「trunk」というフォルダができているはずです。
*その「trunk」に自分の作ったプラグインファイルを全部入れましょう。
*そこまでできたら、リモートリポジトリに入れます。(チェックインと言います)

ここからターミナルを使います。

# Create a local directory on your machine to house
# a copy of the repository.

#自分のローカル上に、リポジトリのコピーが入ったディレクトリを作ります。

$ mkdir my-local-dir

*mkdirはディレクトリを作るという命令。
*my-local-dirは好きな名前でディレクトリ名をつける。

# Check out the repository

#リポジトリをチェックアウトします。
(svn上のデータをローカルにダウンロードしてくる、ということ)

$ svn co http://plugins.svn.wordpress.org/your-plugin-name my-local-dir
> A	my-local-dir/trunk
> A	my-local-dir/branches
> A	my-local-dir/tags
> Checked out revision 11325.

*your-plugin-nameは、自分のプラグイン名を入れてください。
*my-local-dirは、さっき作ったローカル上のフォルダ名(ディレクトリ名)を入れてください。
*trunk、branches、tagsの3つ新規ディレクトリがローカル上にダウンロード(check out)されます。

# As you can see, subversion has added ( “A” for “add” )
# all of the directories from the central repository to
# your local copy.

#サブバージョンは、リモートリポジトリからローカルリポジトリへ全てのディレクトリを追加します。(”A” は”追加する”という意味です )

# Copy the plugin files to the local copy.
# Put everything in the trunk/ directory for now.

#プラグインファイルをtrunkディレクトリに全部入れてください。

$ cd my-local-dir/
my-local-dir/$ cp ~/my-plugin.php trunk/my-plugin.php
my-local-dir/$ cp ~/readme.txt trunk/readme.txt
# Let subversion know you want to add those new files
# back into the central repository.

#これで、サブバージョンが、新しいファイルをリモートリポジトリに追加させる準備が整いました。

my-local-dir/$ svn add trunk/*
> A	trunk/my-plugin.php
> A	trunk/readme.txt

*「svn add trunk/*」と入力します。
*すると自動的に、trunkの中身が追加されます。

# Now check in the changes back to the central repository.
# Give a message to the check in.

#さあ、いよいよリモートリポジトリに変更箇所をアップロード(チェックイン)します。
#チェックイン時のメッセージを入れてください。

my-local-dir/$ svn ci -m 'Adding first version of my plugin'
> Adding	trunk/my-plugin.php
> Adding	trunk/readme.txt
> Transmitting file data .
> Committed revision 11326.

*「svn ci -m」の後にシングルクォーテーションで囲んでメッセージを入力してください。
*上記では、「Adding first version of my plugin」と入れました。
*実際にはこの後、WordPress.orgへのログインパスワードを要求されます。
*自分のWordPress.orgパスワードを入れてください。

# All done!

# 完了です!

まとめ

一行ずつ、丁寧に読んでいけば、入力する箇所はほんのちょっとなんで、なんてことない作業のはずなんですけどね・・・。バージョン管理システムが何なのかを理解していないと、なんでこんな方法でアップロードするのか、よくわかんないですよね。きっと。

ちなみにタスク1は最初にプラグインを登録する時のやり方で、この後、ファイルを修正する方法としてタスク2があるんですが、それはまた別の機会に。

プラグインを作ってWordPress.orgの公式サイトに登録したいけど、申請が通った後、どうすればいいのか迷っている方がもしいたら、この記事が多少の助けになれば嬉しいです。


shoko administrator

フリーランスのWeb制作者。WordPressのサイト構築、およびWebデザインとディレクション。専門学校HAL東京にてWEB学科の講師をしています。WordPressコミュニティに出没。趣味は合気道。