LoginSignup
8
15

More than 5 years have passed since last update.

Repo

Last updated at Posted at 2017-07-10

複数の git レポジトリを管理する repo というツール https://gerrit.googlesource.com/git-repo/ について調べた。Android や Automotive Grade Linux (AGL) のビルドに使われる。

インストール

公式サイト? https://source.android.com/source/downloading#installing-repo によると

curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

のようにダウンロードしてパスを通す。repo コマンドの中身は repo 本体をインストールする Python スクリプトのインストーラになっている。

環境作成

repo init -u URL

によって環境を設定すると、現在のディレクトリで二つの事が起こる。

  • .repo/repo に repo 本体をダウンロードする。
  • .repo/manifests に URL から clone した git レポジトリを展開する。このディレクトリに manifest file が置いてある。
    • .repo/manifests/default.xml から manifest.xml にシンボリックリンクを張る。
    • .repo/manifests.git に .repo/manifests/.git と似たような物が作られる。

つまり自分で repo を別の目的で使うには manifest file を書いた git レポジトリを作り、repo init で参照すると良いという事になる。

ローカルの構成を変更する場合、.repo/manifests を編集してから commit し、revision を指定する。

repo init -b revision

ソースコードの同期 repo sync

repo sync

で manifest file に書いてあるレポジトリとソースコードを同期する。具体的には以下の事を行う。

その他

https://source.android.com/source/using-repo に色々なコマンドがある。

  • repo status: repo の内容 (manifest revision) とローカルでの変更差分を表示する。
  • repo sync -d (project) あるプロジェクトをトピックブランチから manifest revision に戻る。

自分で Manifest を作る

自分で複数の git repository を管理する manifest を書いてみる。例えば、github から propella/prolog と propella/AlligatorEggs という二つのプロジェクトをダウンロードし、それぞれ prolog と eggs に配置するには以下のようなファイル default.xml を一つだけ持つレポジトリを作成して、repo init -u の引数に指定すれば良い。(レポジトリがローカルにある場合はローカルパスで良い)

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
  <remote name="github" fetch="https://github.com/" />
  <project name="propella/prolog" path="prolog" remote="github" revision="master" />
  <project name="propella/AlligatorEggs" path="eggs" remote="github" revision="master" />
</manifest>

Repo を使った開発

.repo/manifests を編集する。

repo sync (project) # project だけ更新
repo status # repo 内の更新状況
repo branches # 現在の利用中のブランチ

以下を参考にした。

8
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
15