visit
Update the cache package to add a new method.
Add the email sending system. It uses the cache package to prevent sending duplicated emails.
Implement the sign-up logic. It depends on the two changes above.
The benefit: This help reviewers with separation of concern. Smaller, isolated changes are easier to be reviewed. They can check the PRs one by one, with each PR containing independent logic. Of course, the email system still requires the cache package to be updated, but we can still review the email system in isolation.
*The downside:*It requires discipline to keep the PRs small and isolated. Usually, while developing the upper PRs, we need to make some changes in the lower PRs. This can be annoying since we have to keep track of what changes in what PR, or constantly switch between PRs to make changes, then rebase the upper ones.
git checkout mybranch/signup # checkout sign up branch
vim features/signup/signup.go # make changes to signup
vim lib/email/email.go # make changes to email package
git add features/signup # commit the signup changes
git commit --amend
git stash # stash the cache changes
git checkout mybranch/email # checkout email branch
git stash pop # apply the cache changes
git add lib/email # commit the email changes
git commit --amend
git checkout mybranch/signup # checkout sign up branch again
git rebase mybranch/email # rebase the signup branch on top of email branch
Given the following commit structure, presented by calling the sl
command:
sl
@ 00f1749f6 30 minutes ago oliver
│ implement user signup
│
@ e0dbbc80e 50 minutes ago oliver
│ implement email package
│
o 4f6928029 Yesterday at oliver
╭─╯ update cache package
│
o 876f46044 Today at 07:45 remote/main
sl goto 00f1749f6 # checkout the sign up code
vim features/signup/signup.go # make changes to signup
vim lib/email/email.go # make changes to email package
sl absorb # magic 👻
With only a single command sl absorb
, sapling will:
Amend the email.go
changes to the email commit.
Amend the signup.go
changes to the signup commit.
sl
: show the commit-graph (or smart-log)
sl status
: show the status of the current branch
sl goto <commit>
: checkout the commit.
sl next
, sl prev
: checkout the next/previous commit.
sl add
, sl remove
, sl forget
: add/remove/untrack files.
sl commit
: commit the changes as a new commit.
sl metaedit
: edit the commit message.
sl absorb
: absorb the changes into the PRs, and rebase the PRs on top of each other.
sl rebase
: rebase the PRs on top of each other.
While git add
adds all changes to the staging area, including new files, deleted files; the corresponding command sl add
will only add new files to the staging area. To remove files, we must use sl remove
. This will be a bit annoying when committing vendor files, since we have to list all deleted files to remove them. I’m not sure if there is a better way:
$ sl status
? vendor/github.com/sample/cache/v2/caching.go
? vendor/github.com/sample/cache/v2/stripe.go
! vendor/github.com/sample/cache/v1/deprecated.go
! vendor/github.com/sample/cache/v1/formatter.go
$ sl add vendor
A vendor/github.com/sample/cache/v2/caching.go
A vendor/github.com/sample/cache/v2/stripe.go
! vendor/github.com/sample/cache/v1/deprecated.go
! vendor/github.com/sample/cache/v1/formatter.go
# Have to list all deleted files to remove, is there a better way? 😞
$ sl remove vendor/github.com/sample/cache/v1/deprecated.go \
vendor/github.com/sample/cache/v1/formatter.go
A vendor/github.com/sample/cache/v2/caching.go
A vendor/github.com/sample/cache/v2/stripe.go
R vendor/github.com/sample/cache/v1/deprecated.go
R vendor/github.com/sample/cache/v1/formatter.go
Sapling provides 2 ways of pushing PRs to GitHub: sl pr
and sl ghstack
. Each has different trade-offs. I prefer using the sl pr
command:
The sl ghstack
command creates a more complex web of PRs. And there are a lot of times when it fails to push the PRs. Try again won’t work. No available fixes. Have to duplicate these PRs again and risk spamming my company repositories. I don’t recommend it.
Sapling recommends using sl pr
, it creates a single commit for each PR. So the reviewer can open the latest commit, and review the changes. Just one more extra click compared to the usual review flow:
It requires cloning a new repository, so you can’t use your familiar git commands. It won’t work with your existing tools, IDE, etc. You have to use the sl web
UI to view changes.