「管理者用Git」の版間の差分

提供:MoodleDocs
移動先:案内検索
編集の要約なし
編集の要約なし
1行目: 1行目:
{{Moodleのインストール}}
{{Moodleのインストール}}
再作成中です - [[利用者:Mitsuhiro Yoshida|Mitsuhiro Yoshida]] ([[利用者・トーク:Mitsuhiro Yoshida|トーク]])
このページでは、本番サーバでMoodleのコピーをどのように保守するか説明しています。Gitを使用することで、簡単にMoodleをアップグレードすることができます。Moodleのコアコードをカスタマイズしている場合は、[[開発者用Git|開発者用Gitガイド]]内の指示に従うことをお勧めします。
このページでは、本番サーバでMoodleのコピーをどのように保守するか説明しています。Gitを使用することで、簡単にMoodleをアップグレードすることができます。Moodleのコアコードをカスタマイズしている場合は、[[開発者用Git|開発者用Gitガイド]]内の指示に従うことをお勧めします。


11行目: 14行目:


自分のOS用のgitをダウンロードしてインストールすれば、この文書内のgitコマンドはそのOSで動作するはずです。
自分のOS用のgitをダウンロードしてインストールすれば、この文書内のgitコマンドはそのOSで動作するはずです。
== Moodle branch names ==
Major Moodle versions each have their own branch in Git. For example, MOODLE_38_STABLE (3.8), MOODLE_39_STABLE (3.9). Development is generally done on branch 'master'. The entire lifetime of that version will stay on that branch. Each release is designated by adding a Git 'tag', for example v3.9.0-beta, v3.9.0-rc1, v3.9.0.


== Gitからコードを入手する ==
== Gitからコードを入手する ==
31行目: 37行目:


Gitは各コマンドに非常に多くのオプションがあり、上記プロセスをコマンド1個で実行することも実際に可能なことに注意してください (練習用に残しておきます!) 。
Gitは各コマンドに非常に多くのオプションがあり、上記プロセスをコマンド1個で実行することも実際に可能なことに注意してください (練習用に残しておきます!) 。
==Git Connection Refused Error==
*If connection refused, use: $ git clone https://github.com/moodle/moodle.git
''fatal: unable to connect to git.moodle.org:
git.moodle.org[0: 34.210.133.53]: errno=Connection refused''
Note that Git has a huge number of options for each command and it's actually possible to do the above process with a single command (left as an exercise!!).


== ファイアウォール背後からのGit ==
== ファイアウォール背後からのGit ==
36行目: 49行目:
Gitは読み出し専用のプロトコル (port 9418) を使用していますが、あなたのファイアウォールでブロックされるかもしれません。もしこの問題が発生した場合は Github の http 版 <nowiki>https://github.com/moodle/moodle.git</nowiki> を使用することができます。これは若干遅いので、可能ならGitプロトコルを使用してください。
Gitは読み出し専用のプロトコル (port 9418) を使用していますが、あなたのファイアウォールでブロックされるかもしれません。もしこの問題が発生した場合は Github の http 版 <nowiki>https://github.com/moodle/moodle.git</nowiki> を使用することができます。これは若干遅いので、可能ならGitプロトコルを使用してください。


== インストールを更新する ==
== Updating your installation with minor releases ==
The Moodle development team performs integration and testing of fixed bugs every Monday and Tuesday. On Wednesday you can install all patches by updating your code. Check the [http://git.moodle.org/gw?p=moodle.git;a=summary shortlog] to see if the official repository has been already updated or not.
 
To update your code to the latest version (on the MOODLE_400_STABLE branch) '''all''' you have to do is:
<pre>
$ cd /path/to/your/moodle/
$ git pull
</pre>
If this is a production site you should still consider the [[Upgrade]] instructions (e.g. take backups).
 
== Upgrading to a newer major release ==
When you want to upgrade to a newer major release, you will need to tell your git installation to track the newer release instead of the release that you currently have installed and are tracking.
You should ensure that you have updated your installation with the latest minor release of your currently installed Moodle version first (as described in the section above). This will also download the changes for newer Moodle versions (but not yet make use of them).
You should put your site into maintenance mode, or disable the website, before starting the upgrade.<syntaxhighlight lang="shell">
cd /path/to/your/moodle/folder
 
# Check which branch you are currently tracking
git branch -a
 
# Make a local branch for the newer release from the remote repo
git branch --track MOODLE_400_STABLE origin/MOODLE_400_STABLE
 
# Switch to track this branch
git checkout MOODLE_400_STABLE
</syntaxhighlight>Your website folder now includes the files for the newer Moodle version, but to complete the Moodle upgrade, you will either need to [[Upgrading|complete the upgrade via the web browser]], or [[Administration via command line|use the command line upgrade script]].
 
== インストールを更新する - 削除予定 ==


Moodle開発チームは、バグ修正の結合とテストを毎週月曜日と火曜日に実施しています。水曜日にコードを更新することですべてのパッチをインストールできます。公式リポジトリが更新されたかどうかは、[https://git.moodle.org/gw?p=moodle.git;a=summary ショートログ]をご覧ください。
Moodle開発チームは、バグ修正の結合とテストを毎週月曜日と火曜日に実施しています。水曜日にコードを更新することですべてのパッチをインストールできます。公式リポジトリが更新されたかどうかは、[https://git.moodle.org/gw?p=moodle.git;a=summary ショートログ]をご覧ください。

2022年9月24日 (土) 15:02時点における版


再作成中です - Mitsuhiro Yoshida (トーク)

このページでは、本番サーバでMoodleのコピーをどのように保守するか説明しています。Gitを使用することで、簡単にMoodleをアップグレードすることができます。Moodleのコアコードをカスタマイズしている場合は、開発者用Gitガイド内の指示に従うことをお勧めします。

Gitを最大限活用できるようにその基本概念の理解のための努力をする価値があります。以下の節を参照してください。特にCVSやSubversionを使ったことがあれば、学習が少し楽になるかもしれません。

Gitを入手する (Windows, OSX, Linux その他)

Gitのサポートは最近までは主にLinux用に閉じていましたが、現在ではほとんどの人気OS用のビルドが利用可能です。

自分のOS用のgitをダウンロードしてインストールすれば、この文書内のgitコマンドはそのOSで動作するはずです。

Moodle branch names

Major Moodle versions each have their own branch in Git. For example, MOODLE_38_STABLE (3.8), MOODLE_39_STABLE (3.9). Development is generally done on branch 'master'. The entire lifetime of that version will stay on that branch. Each release is designated by adding a Git 'tag', for example v3.9.0-beta, v3.9.0-rc1, v3.9.0.

Gitからコードを入手する

ここではコマンドライン版のGitを説明しています。グラフィカルなクライアントはコマンドライン版のラッパーに過ぎないので、必要なパラメータは極めて簡単に推測できるはずです。

Moodleの公式gitリポジトリは git://git.moodle.org/moodle.git にあります (公式クローンは git://github.com/moodle/moodle.git にあります)。ローカルチェックアウトを初期化するには次のようにしてください:

$ cd /path/to/your/webroot
$ git clone git://git.moodle.org/moodle.git                       (1)
$ cd moodle
$ git branch -a                                                   (2)
$ git branch --track MOODLE_38_STABLE origin/MOODLE_38_STABLE     (3)
$ git checkout MOODLE_38_STABLE                                   (4)
  • コマンド (1) は、新しいローカルリポジトリを上流 (upstream、つまりリモートサーバ) 上の moodle.git リポジトリのクローンとして初期化します。この上流リポジトリはデフォルトで「origin」と呼ばれます。これにより moodle という名前の新規ディレクトリが作成され、ここにすべてのファイルがダウンロードされます。この操作は、Moodleの全バージョンの全履歴を取得するので、すこし時間がかかります。
  • コマンド (2) は、すべての利用可能なブランチを一覧表示します。
  • コマンド (3) は、MOODLE_38_STABLE という新しいローカルブランチを作成して、上流リポジトリのリモートブランチ「MOODLE_38_STABLE」を追跡 (track) するよう設定します。
  • コマンド (4) では、新しく作成したローカルブランチに実際にスイッチします。

Gitは各コマンドに非常に多くのオプションがあり、上記プロセスをコマンド1個で実行することも実際に可能なことに注意してください (練習用に残しておきます!) 。

Git Connection Refused Error

fatal: unable to connect to git.moodle.org: git.moodle.org[0: 34.210.133.53]: errno=Connection refused

Note that Git has a huge number of options for each command and it's actually possible to do the above process with a single command (left as an exercise!!).

ファイアウォール背後からのGit

Gitは読み出し専用のプロトコル (port 9418) を使用していますが、あなたのファイアウォールでブロックされるかもしれません。もしこの問題が発生した場合は Github の http 版 https://github.com/moodle/moodle.git を使用することができます。これは若干遅いので、可能ならGitプロトコルを使用してください。

Updating your installation with minor releases

The Moodle development team performs integration and testing of fixed bugs every Monday and Tuesday. On Wednesday you can install all patches by updating your code. Check the shortlog to see if the official repository has been already updated or not.

To update your code to the latest version (on the MOODLE_400_STABLE branch) all you have to do is:

$ cd /path/to/your/moodle/
$ git pull

If this is a production site you should still consider the Upgrade instructions (e.g. take backups).

Upgrading to a newer major release

When you want to upgrade to a newer major release, you will need to tell your git installation to track the newer release instead of the release that you currently have installed and are tracking. You should ensure that you have updated your installation with the latest minor release of your currently installed Moodle version first (as described in the section above). This will also download the changes for newer Moodle versions (but not yet make use of them).

You should put your site into maintenance mode, or disable the website, before starting the upgrade.

cd /path/to/your/moodle/folder

# Check which branch you are currently tracking
git branch -a

# Make a local branch for the newer release from the remote repo
git branch --track MOODLE_400_STABLE origin/MOODLE_400_STABLE

# Switch to track this branch
git checkout MOODLE_400_STABLE

Your website folder now includes the files for the newer Moodle version, but to complete the Moodle upgrade, you will either need to complete the upgrade via the web browser, or use the command line upgrade script.

インストールを更新する - 削除予定

Moodle開発チームは、バグ修正の結合とテストを毎週月曜日と火曜日に実施しています。水曜日にコードを更新することですべてのパッチをインストールできます。公式リポジトリが更新されたかどうかは、ショートログをご覧ください。

コードを (MOODLE_38_STABLE ブランチの) 最新版に更新するために必要なことの すべて は次のコマンドだけです:

$ cd /path/to/your/moodle/
$ git pull

これが本番サイトの場合は、アップグレードにある指示もよく考慮するべきです (バックアップをとるなど)。

拡張機能をGitリポジトリからインストールする

これはあなたのMoodleリポジトリに他のGitリポジトリからのプラグイン追加を扱うための一方法です。もう一つの方法はGitサブモジュールを使うことですが、執筆時点ではGitのやや荒削りな機能の一つであり、上級者向けオプションとみなすべきです。

例えば、自分の Moodle 3.5 にen:Certificate moduleをGitリポジトリからインストールしたいとしましょう。

$ cd /path/to/your/moodle/
$ cd mod                                                          (1)
$ git clone https://github.com/markn86/moodle-mod_certificate.git certificate     (2)
$ cd certificate
$ git checkout -b MOODLE_38_STABLE origin/MOODLE_38_STABLE        (3)
$ git branch -d master                                            (4)

コマンド (1) は、カレントディレクトリを、ローカルなMoodleクローンの mod フォルダに変更します。コマンド (2) は新しいサブディレクトリ certificate 内に、素のCertificateリポジトリのローカルクローンを作成します。コマンド (3) は新しいローカルブランチを作成し、Moodle 3.5 に対応するCertificateバージョンによりリモートブランチを追跡します。コマンド (4) は、(2) の git-clone により自動的に作成された master ブランチが本番のチェックアウトでは不要なので、これを削除します。

注意: リポジトリをクローンする前に、メンテナに直接質問するか、あるいはあてずっぽうでよければ利用できるブランチを確認するためにコマンド (3) の前に以下のコマンドを実行することで、あなたのMoodleブランチとモジュールの互換性をまず確認するべきです。

$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/MOODLE_20_STABLE
  remotes/origin/MOODLE_21_STABLE
  remotes/origin/MOODLE_22_STABLE
  remotes/origin/MOODLE_23_STABLE
  remotes/origin/MOODLE_24_STABLE
  remotes/origin/MOODLE_25_STABLE
  remotes/origin/MOODLE_26_STABLE
  remotes/origin/MOODLE_27_STABLE
  remotes/origin/MOODLE_28_STABLE
  remotes/origin/MOODLE_29_STABLE
  remotes/origin/MOODLE_30_STABLE
  remotes/origin/MOODLE_31_STABLE
  remotes/origin/master

これにより、存在しないブランチに対してコマンド (3) を実行してしまい、次のようなエラーが表示されるのを防ぐことができます。

$ git checkout -b MOODLE_31_STABLE origin/MOODLE_31_STABLE
fatal: git checkout: updating paths is incompatible with switching branches.
Did you intend to checkout 'origin/MOODLE_31_STABLE' which can not be resolved as commit?

注意: 上のエラーを修正するには、これを実行します: "git fetch origin MOODLE_31_STABLE:LOCAL_MOODLE_31_STABLE"

この時点で、メインのMoodleクローンの無視ファイルリストに新しいディレクトリ mod/certificate/ を追加しておくとよいでしょう。でないと、メインのクローンの status を見るたびに、チェックインしていない新しいコードがあると言われ続けることになります。

$ cd /path/to/your/moodle/
$ echo /mod/certificate/ >> .git/info/exclude

インストールしたMoodleを更新するには、今や両方のGitリポジトリにおいて上流から変更を pull しなければなりません。

$ cd /path/to/your/moodle/
$ git pull
$ cd mod/certificate
$ git pull

これらのコマンドを記載したシェルスクリプトをインストールしたMoodleのrootディレクトリに置いておくのも非常にいい考えです。でないと、メインのMoodleリポジトリ内のどこにGitリポジトリがあるかなどすぐ忘れてしまいます。

拡張機能をGitサブモジュールを用いてインストールおよび保守する

前節で述べたように、これは上級者向けです。 ですので、Gitとそのコマンドに関していくらか経験をもっていることが必要です。 ステップバイステップに説明しますが、これらのコマンドが何をしているか理解しているとステップを追いかける役に立ちます。


上級者向けのオプションとコマンドは [Git book] にあります。 Gitサブモジュールに関する疑問があれば、まずは上記サイトをご覧ください。

既存のMoodleに新しい拡張をインストールする

前節と同様、en:Certificate moduleを例に使います。

$ cd /path/to/your/moodle
$ git submodule add https://github.com/markn86/moodle-mod_certificate.git mod/certificate

注意: Gitはリポジトリに次の二つのファイルがあると報告します:

$ git status
# On branch MOODLE_29_STABLE
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	new file:   .gitmodules
#	new file:   mod/certificate
#

.gitmodules ファイルにはすべてのサブモジュールのローカルパスとURLが格納されます。 リポジトリを後でクローンするつもりであれば、これをコミットしておく必要があります (en:Moodle development environment with Git submodules のページをご覧ください)。 自動生成された設定は不十分かもしれないので、コミットの前に、プラグインのGitリポジトリの設定をしっかりチェックします。 あなたのリポジトリでMoodleのバージョンに対応するリモートブランチを追跡するようにしておくと、将来の更新の役に立ちます。

$ cd mod/certificate
$ git branch -avv
* master                          345f5b1 [origin/master] Replaced deprecated function
  remotes/origin/HEAD             -> origin/master
  remotes/origin/MOODLE_20_STABLE 1aa1040 Added option to print 'grade category' grade
  remotes/origin/MOODLE_21_STABLE 1aa1040 Added option to print 'grade category' grade
  remotes/origin/MOODLE_22_STABLE 1aa1040 Added option to print 'grade category' grade
  remotes/origin/MOODLE_23_STABLE fe047de Check that the function exists rather than relying on the Moodle version
  remotes/origin/MOODLE_24_STABLE 1051f7d CONTRIB-4892 Fixed the email to others functionality
  remotes/origin/MOODLE_25_STABLE cdb221a CONTRIB-4946: Removed character from language file breaking AMOS
  remotes/origin/MOODLE_26_STABLE 696802a Increased version
  remotes/origin/MOODLE_27_STABLE d3c0379 Increased version
  remotes/origin/MOODLE_28_STABLE fa8df83 Increased version
  remotes/origin/MOODLE_29_STABLE 3f03740 Replaced deprecated function
  remotes/origin/master           345f5b1 Replaced deprecated function

リモートリポジトリは master なので、Git は origin/master を追跡する master を自動的に作成しています。 ですので、新しいブランチを作成して適切なリモートブランチを追跡するようにします。 もちろんこれは、リモートリポジトリがそのブランチを提供している場合にのみ可能です。

$ git checkout -b MOODLE_29_STABLE origin/MOODLE_29_STABLE
Branch MOODLE_29_STABLE set up to track remote branch MOODLE_29_STABLE from origin.
Switched to a new branch 'MOODLE_29_STABLE'
$ git branch -D master
Deleted branch master (was 345f5b1).

master ブランチを削除することは必須ではありませんが、残していても役に立ちません。 実際、これ以降、この設定に触れる必要はありません。

最後のステップはメインリポジトリに変更をコミットすることです。

$ cd /path/to/your/moodle
$ git commit -a -m "New extension mod_certificate installed"

コミットが新しいGitサブモジュールに関する変更のみを含むように確認することが必要です (-a はステージされていない変更もすべてコミットするため)。

Gitサブモジュールを保守する

サブモジュール群の保守は非常に簡単です。 Moodleリポジトリにいくつかサブモジュールをインストールしてあるとします。 mod_mylittleextension 拡張はこの例のテスト用のシナリオとして用意したフェイクのプラグインであることに注意してください。 Moodleの公式モジュールではありません。サブモジュールを一度にすべて更新するには、以下の入力します:

$ cd /path/to/your/moodle
$ git submodule foreach git pull
Entering 'block/coursefeedback'
Already up-to-date.
Entering 'mod/certificate'
Already up-to-date.
Entering 'mod/mylittleextension'
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
From /local/repositories/mle
   89d9eae..64c122d  master     -> origin/master
Updating 89d9eae..64c122d
Fast-forward
 index.html  |    9 +++++++++
 version.php |    6 +++---
 2 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 index.html
$ git status
# On branch MOODLE_29_STABLE
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   mod/mylittleextension (new commits)
#

git submodule foreach [another command] コマンドは、すべてのサブモジュールリポジトリを渡り歩いて [another command] で指定されたものを実行します。 今回の場合は git pull です。 したがって、mylittleextension モジュールが更新されますが、メインのリポジトリは変更がコミットされるまではクリーンではありません:

$ git commit -a -m "Plugin updates"

プラグインをGitサブモジュールにより保守することは、更新プロセスを単純化する以外にも役に立ちます。 より大きなスケールで、これはMoodleプロジェクトを保守するのに使用することもできます。Moodleプロジェクトでは複数の開発者が外部プラグインを手動で取り込むことなくMoodleの正確なコピーを持つ必要があります。 この話題については en:Moodle development environment with Git submodules のページをご覧ください。

関連情報

Moodleフォーラムディスカッション
外部リソース