日曜日の午後の気分転換にちょっとSaplingを触ってみる
Sapling?
https://sapling-scm.com/
- Meta(旧Facebook)が作ったソースコントロールシステム。Meta社内で使われてる
- ユーザビリティとスケーラビリティに重点を置いてる
- 仮想ファイルシステム(まだ公開されてない)と合わせて使うと巨大なリポジトリも扱える
- GitHubと連携して使うことも可能
へー。コマンドが色々ユーザーフレンドリーみたい。モノレポに対して使いやすい感じなのかな?個人的にはコードレビューの仕組みが気になる。じゃ、見てみよう
Getting Started
Macなのでbrewでインストールして
❯ brew install sapling
Getting Startedを見ながらやってみる
ユーザー設定をして
❯ sl config --user ui.username "名前 <メールアドレス>"
GitHub連携のためにGitHub CLI(gh)のログインを設定しておく
❯ gh auth login --git-protocol https
Clone
適当に作ったGitHubリポジトリをクローンしてきて
❯ sl clone https://github.com/bufferings/try-sapling.git
❯ cd try-sapling
Gitのコマンド使えるのかな?と思ったら .git
ディレクトリがなかった。代わりに .sl
がある。へー。
❯ ls -al
total 8
drwxr-xr-x 4 bufferings staff 128 Dec 18 16:47 .
drwxr-xr-x 3 bufferings staff 96 Dec 18 16:46 ..
drwxr-xr-x 16 bufferings staff 512 Dec 18 16:46 .sl
-rw-r--r-- 1 bufferings staff 13 Dec 18 16:46 README.md
sl
コマンドをオプションなしで実行するとコミットグラフが見える(作ったばっかりだから今は何もないけど)
❯ sl
@ 57f903ea2 6 minutes ago bufferings+github remote/main
Initial commit
Add
変更を加えてみる
ファイルを作って
❯ touch hello.txt
❯ touch hello2.txt
確認してみて
❯ sl status
? hello.txt
? hello2.txt
一個だけ追加してみる?
❯ sl add hello.txt
ふむふむ。A
が追加されたもので ?
がまだ追加されてないものってことなんだろうな
❯ sl status
A hello.txt
? hello2.txt
変更を加えてみる
❯ echo 'Hello, World!' > hello.txt
特に変わってない
❯ sl status
A hello.txt
? hello2.txt
Gitと違ってインデックスがないとのこと。もう Hello, World!
の変更は適用されてる
Commit
じゃ、コミットしてみよう
❯ sl commit -m 'my first commit with Sapling'
コミットグラフ
❯ sl
@ cc9195646 21 seconds ago bufferings
│ my first commit with Sapling
│
o 57f903ea2 22 minutes ago remote/main
ステータス
❯ sl status
? hello2.txt
Stack
スタックって複数のコミットの積み重ねのことを指すみたいだけどSaplingのドキュメントによく出てくるから特有の概念として覚えておいたらいいのかな?
Getting Startedに従って適当にコミットを追加してスタックを作る
❯ echo foo > foo.txt ; sl add foo.txt ; sl ci -m 'adding foo'
❯ echo bar > bar.txt ; sl add bar.txt ; sl ci -m 'adding bar'
❯ echo baz > baz.txt ; sl add baz.txt ; sl ci -m 'adding baz'
❯ sl
@ 64c381a9f 3 seconds ago bufferings
│ adding baz
│
o 4220bb64a 8 seconds ago bufferings
│ adding bar
│
o 65280397f 14 seconds ago bufferings
│ adding foo
│
o cc9195646 3 minutes ago bufferings
│ my first commit with Sapling
│
o 57f903ea2 25 minutes ago remote/main
この @
が今いるコミット。これを sl go bottom
や sl go top
sl next
sl prev
で移動できる
❯ sl go bottom
0 files updated, 0 files merged, 3 files removed, 0 files unresolved
❯ sl
o 64c381a9f 2 minutes ago bufferings
│ adding baz
│
o 4220bb64a 2 minutes ago bufferings
│ adding bar
│
o 65280397f 2 minutes ago bufferings
│ adding foo
│
@ cc9195646 5 minutes ago bufferings
│ my first commit with Sapling
│
o 57f903ea2 27 minutes ago remote/main
そのコミットの状態になってる
❯ ls -al
total 16
drwxr-xr-x 6 bufferings staff 192 Dec 18 17:10 .
drwxr-xr-x 3 bufferings staff 96 Dec 18 16:46 ..
drwxr-xr-x 23 bufferings staff 736 Dec 18 17:10 .sl
-rw-r--r-- 1 bufferings staff 13 Dec 18 16:46 README.md
-rw-r--r-- 1 bufferings staff 14 Dec 18 16:58 hello.txt
-rw-r--r-- 1 bufferings staff 0 Dec 18 16:55 hello2.txt
top に戻っておこう
❯ sl go top
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
❯ sl
@ 64c381a9f 12 minutes ago bufferings
│ adding baz
│
o 4220bb64a 12 minutes ago bufferings
│ adding bar
│
o 65280397f 13 minutes ago bufferings
│ adding foo
│
o cc9195646 16 minutes ago bufferings
│ my first commit with Sapling
│
o 57f903ea2 38 minutes ago remote/main
GUIで操作
GUI で操作することもできる
❯ sl web
started a new server
ってするとブラウザで画面が開く。便利そう

ん?どうやってWebサーバーを止めるんだろう?と思ってヘルプを見てみたら --kill
オプションでいいみたい
❯ sl web --kill
killed Sapling Web server process 26955
VS Code extension もあるとのこと
プルリクエスト
いちばん興味あるところ。いくつか方法がある中で一番シンプルなのは sl pr
ということなのでやってみる
❯ sl pr
pushing 4 to https://github.com/bufferings/try-sapling.git
created new pull request: https://github.com/bufferings/try-sapling/pull/1
created new pull request: https://github.com/bufferings/try-sapling/pull/2
created new pull request: https://github.com/bufferings/try-sapling/pull/3
created new pull request: https://github.com/bufferings/try-sapling/pull/4
updated body for https://github.com/bufferings/try-sapling/pull/1
updated body for https://github.com/bufferings/try-sapling/pull/4
updated body for https://github.com/bufferings/try-sapling/pull/2
updated body for https://github.com/bufferings/try-sapling/pull/3
おー。pushして、コミットごとにプルリクエストを作ったな?全部mainブランチがdestinationだな

コミットのところにプルリクエストの番号が表示されるようになった
❯ sl
@ 64c381a9f 27 minutes ago bufferings #4
│ adding baz
│
o 4220bb64a 27 minutes ago bufferings #3
│ adding bar
│
o 65280397f 27 minutes ago bufferings #2
│ adding foo
│
o cc9195646 31 minutes ago bufferings #1
│ my first commit with Sapling
│
o 57f903ea2 53 minutes ago remote/main
sl ssl
でプルリクエストのステータスも表示される
❯ sl ssl
@ 64c381a9f 34 minutes ago bufferings #4 Unreviewed
│ adding baz
│
o 4220bb64a 34 minutes ago bufferings #3 Unreviewed
│ adding bar
│
o 65280397f 34 minutes ago bufferings #2 Unreviewed
│ adding foo
│
o cc9195646 38 minutes ago bufferings #1 Unreviewed
│ my first commit with Sapling
│
o 57f903ea2 60 minutes ago remote/main
ReviewStack
コミットごとのプルリクエストのレビューのためにReviewStackが用意されてる
リポジトリのドメインの github.com
を reviewstack.dev
にしてあげれば見える。ReviewStackからGitHubに対するアクセス許可が必要
↑で作ったプルリクエストに対して、コミットごとの差分をレビューできるみたい

まだ機能は足りてなさそうだし、今いろいろやろうとしてるところなのかな
面白かった
ひとまずGetting Startedをやってみた感じだと、これから色々と公開されて充実していくのかなと思った
Gitのコマンドをシンプルにしてるみたいなので、その辺りも慣れると分かりやすいのかな?Gitに慣れてるからまだあんまりよくわかんない
正直なところ、まだコミットごとのプルリクエストの狙っているところも、よく理解できてないんだけど、プルリクエストを出した後にコミットに対して変更を加えるとそれがプルリクエストに反映されるみたいなことが書いてあるので、しばらくしたらまたもうちょっと深く触ってみようかな
ちょうどいい気分転換になったやー。今日はカレーつくろう