Skip to content

Commit b3124de

Browse files
authored
doc: Update for GitLab support (#487)
Update documentation website to reflect the new GitLab support from #477. refs #485
1 parent 3b6d37f commit b3124de

File tree

19 files changed

+450
-176
lines changed

19 files changed

+450
-176
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
git-spice is a tool for stacking Git branches.
1515
It lets you manage and navigate stacks of branches,
1616
conveniently modify and rebase them,
17-
and create GitHub Pull Requests from them.
17+
and create GitHub Pull Requests or GitLab Merge Requests from them.
1818

1919
See <https://abhinav.github.io/git-spice/> for more details.
2020

@@ -24,7 +24,7 @@ Usage looks roughly like this:
2424
# Stack a branch on top of the current branch.
2525
$ gs branch create feat1
2626

27-
# Stack aonther branch on top of feat1.
27+
# Stack another branch on top of feat1.
2828
$ gs branch create feat2
2929

3030
# Submit pull requests for feat1 and feat2.
@@ -51,8 +51,8 @@ $ gs sr # stack restack
5151
## Features
5252

5353
- Create, edit, and navigate stacks of branches with ease.
54-
- Create and update GitHub Pull Requests for the entire stack
55-
or parts of it with a single command.
54+
- Submit the entire stack or parts of it with a single command.
55+
Supports GitHub and GitLab.
5656
- Keep using your existing workflow and adopt git-spice incrementally.
5757
- Completely offline operation with no external dependencies
5858
until you push or pull from a remote repository.

doc/hooks/badge.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
"""
2+
Adds a badgge shortcode in the form:
3+
4+
<!-- gs:badge ICON TEXT -->
5+
6+
Where ICON is a mkdocs-material icon name
7+
and TEXT is the text to display.
8+
"""
9+
10+
import re
11+
12+
from mkdocs.config.defaults import MkDocsConfig
13+
from mkdocs.structure.files import Files
14+
from mkdocs.structure.pages import Page
15+
16+
_tag_re = re.compile(r'<!-- gs:badge ([^ ]+) (.+?) -->')
17+
18+
19+
def on_page_markdown(
20+
markdown: str,
21+
page: Page,
22+
config: MkDocsConfig,
23+
files: Files,
24+
**kwargs
25+
) -> str:
26+
def replace(match: re.Match) -> str:
27+
icon = match.group(1)
28+
text = match.group(2)
29+
return ''.join([
30+
'<span class="mdx-badge">',
31+
*[
32+
'<span class="mdx-badge__icon">',
33+
f':{icon}:',
34+
'</span>',
35+
],
36+
*[
37+
'<span class="mdx-badge__text">',
38+
text,
39+
'</span>',
40+
],
41+
'</span>'
42+
])
43+
44+
return _tag_re.sub(replace, markdown)

doc/hooks/replace.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""
2+
Simple text replacement hooks.
3+
"""
4+
5+
from mkdocs.config.defaults import MkDocsConfig
6+
from mkdocs.structure.files import Files
7+
from mkdocs.structure.pages import Page
8+
9+
10+
REPLACEMENTS = {
11+
'<!-- gs:github -->': ':simple-github: GitHub',
12+
'<!-- gs:gitlab -->': ':simple-gitlab: GitLab',
13+
'<!-- gs:badge:github ': '<!-- gs:badge simple-github GitHub ',
14+
'<!-- gs:badge:gitlab ': '<!-- gs:badge simple-gitlab GitLab ',
15+
}
16+
17+
18+
def on_page_markdown(
19+
markdown: str,
20+
page: Page,
21+
config: MkDocsConfig,
22+
files: Files,
23+
**kwargs
24+
) -> str:
25+
for key, value in REPLACEMENTS.items():
26+
markdown = markdown.replace(key, value)
27+
return markdown
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Select a Forge: 
2+

3+
▶ github
4+
gitlab

doc/mkdocs.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ theme:
4646
features:
4747
- content.action.edit
4848
- content.code.copy
49+
- content.tabs.link
4950
- content.tooltips
5051
- header.autohide
5152
- navigation.expand
@@ -68,13 +69,16 @@ plugins:
6869
- redirects:
6970
redirect_maps:
7071
'how-to.md': 'recipes.md'
72+
'guide/pr.md': 'guide/cr.md'
7173
- search
7274
- social:
7375
enabled: !ENV [CI, false]
7476

7577
hooks:
78+
- hooks/replace.py
7679
- hooks/cliref.py
7780
- hooks/released.py
81+
- hooks/badge.py
7882
- hooks/footer.py
7983
- hooks/freeze.py
8084
- hooks/listing.py
@@ -110,7 +114,7 @@ nav:
110114
- guide/index.md
111115
- guide/concepts.md
112116
- guide/branch.md
113-
- guide/pr.md
117+
- guide/cr.md
114118
- guide/limits.md
115119
- guide/internals.md
116120
- Setting up:

doc/src/cli/config.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,20 @@ See also: [GitHub Enterprise](../setup/auth.md#github-enterprise).
7676
URL of the GitLab instance used for GitLab requests.
7777
Defaults to `$GITLAB_URL` if set, or `https://gitlab.com` otherwise.
7878

79+
See also [GitLab Self-Hosted](../setup/auth.md#gitlab-self-hosted).
80+
7981
### spice.forge.gitlab.oauth.clientID
8082

8183
<!-- gs:version unreleased -->
8284

8385
Client ID for OAuth authentication with GitLab.
84-
Default to git-spice's built-in Client ID in https://gitlab.com.
85-
It should be set to a custom value if you are running your own GitLab Self-Managed instance.
86+
87+
Defaults to git-spice's built-in Client ID (valid only for https://gitlab.com)
88+
or `$GITLAB_OAUTH_CLIENT_ID` if set.
89+
90+
For Self-Hosted GitLab instances, you must set this value to a custom Client ID.
91+
92+
See also [GitLab Self-Hosted](../setup/auth.md#gitlab-self-hosted).
8693

8794
### spice.log.all
8895

doc/src/faq.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ keeping them up-to-date and in sync with each other.
3131

3232
- [The stacking workflow](https://www.stacking.dev/)
3333

34-
## Where is the GitHub authentication token stored?
34+
## Where is the authentication token stored?
3535

3636
git-spice stores the GitHub authentication in a system-specific secure storage.
3737
See [Authentication > Safety](setup/auth.md#safety) for details.
3838

39-
## Why doesn't git-spice create one PR per commit?
39+
## Why doesn't git-spice create one CR per commit?
4040

4141
With tooling like this, there are two options:
4242
each commit is an atomic unit of work, or each branch is.
4343
While the former might be more in line with Git's original philosophy,
44-
the latter is more practical for most teams with GitHub-based workflows.
44+
the latter is more practical for most teams with GitHub or GitLab-based workflows.
4545

4646
With a PR per commit, when a PR gets review feedback,
4747
you must amend that commit with fixes and force-push.
@@ -52,7 +52,7 @@ However, with a PR per branch, you can keep the original changes separate
5252
from follow-up fixes, even if the branch is force-pushed.
5353
This makes it easier for PR reviewers to work through the changes.
5454

55-
And with GitHub squash-merges, you can still get a clean history
55+
And with squash-merges, you can still get a clean history
5656
consisting of atomic, revertible commits on the trunk branch.
5757

5858
## How does git-spice interact with `rebase.updateRefs`?

doc/src/guide/branch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Branch stacks
2+
title: Local stacks
33
icon: octicons/git-branch-16
44
description: >-
55
Manage, navigate, and manipulate stacks of branches with git-spice.

doc/src/guide/concepts.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ text "Sibling" with s at F.n
8282
This is "main" or "master" in most repositories.
8383
Trunk is the only branch that does not have a base branch.
8484

85+
**Change Request**
86+
: Change Request refers to a single merge-able unit of work
87+
submitted to GitHub or GitLab.
88+
Each Change Request corresponds to a branch.
89+
On GitHub, these are called Pull Requests,
90+
and on GitLab, they are called Merge Requests.
91+
Since git-spice supports both platforms,
92+
the term Change Request is used to refer to both.
93+
8594
**Stack**
8695
: A stack is a collection of branches stacked on top of each other
8796
in a way that each branch except the trunk has a base branch.

doc/src/guide/pr.md renamed to doc/src/guide/cr.md

Lines changed: 63 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,36 @@
11
---
2-
title: PR stacks
2+
title: Submitting stacks
33
icon: octicons/git-pull-request-16
44
description: >-
5-
Create and update stacked pull requests from a stack of branches.
5+
Create and update stacked change requests from a stack of branches.
66
---
77

8-
# Working with Pull Requests
8+
# Working with remote repositories
99

1010
!!! note
1111

12-
This page assumes you're using git-spice with GitHub.
13-
If you're using a different Git hosting service,
14-
you can still use git-spice, but some features may not be available.
12+
This page assumes you are using one of the supported Git forges.
13+
These are:
14+
15+
- <!-- gs:github -->
16+
- <!-- gs:gitlab --> (<!-- gs:version unreleased -->)
17+
18+
If you're using a different service,
19+
you can still use git-spice,
20+
but some features may not be available.
1521

1622
See:
1723

18-
- [:material-tooltip-check: Recipes > Working with non-GitHub remotes](../recipes.md#working-with-non-github-remotes)
24+
- [:material-tooltip-check: Recipes > Working with unsupported remotes](../recipes.md#working-with-unsupported-remotes)
1925
- [:material-frequently-asked-questions: FAQ > Will git-spice add support for other Git hosting services](../faq.md#will-git-spice-add-support-for-other-git-hosting-services)
2026

21-
## Submitting pull requests
27+
## Submitting change requests
28+
29+
!!! info
30+
31+
git-spice uses the term *Change Request* to refer to submitted branches.
32+
These corespond to Pull Requests on GitHub,
33+
and to Merge Requests on GitLab.
2234

2335
When your local changes are ready,
2436
use the following commands to submit your changes upstream:
@@ -33,10 +45,10 @@ use the following commands to submit your changes upstream:
3345
submits all branches in the stack
3446

3547
Branch submission is an idempotent operation:
36-
pull requests will be created for branches that don't already have them,
48+
change requests will be created for branches that don't already have them,
3749
and updated for branches that do.
3850

39-
For new pull requests, these commands will prompt you for PR information.
51+
For new change requests, these commands will prompt you for CR information.
4052
For example:
4153

4254
```freeze language="ansi"
@@ -52,11 +64,17 @@ For example:
5264

5365
### Navigation comments
5466

55-
Pull Requests created by git-spice will include a navigation comment
67+
Change Requests created by git-spice will include a navigation comment
5668
at the top with a visual representation of the stack,
5769
and the position of the current branch in it.
5870

59-
![Example of a stack navigation comment](../img/stack-comment.png)
71+
=== "<!-- gs:github -->"
72+
73+
![Example of a stack navigation comment on GitHub](../img/stack-comment.png)
74+
75+
=== "<!-- gs:gitlab -->"
76+
77+
![Example of a stack navigation comment on GitLab](../img/stack-comment-glab.png)
6078

6179
This behavior may be changed with the $$spice.submit.navigationComment$$
6280
configuration key.
@@ -86,7 +104,7 @@ you may also specify title and body directly.
86104

87105
!!! info "Setting draft status non-interactively"
88106

89-
Pull requests may be marked as draft or ready for review
107+
Change requests may be marked as draft or ready for review
90108
non-interactively with the `--draft` and `--no-draft` flags.
91109

92110
By default, the submit commands will leave
@@ -123,35 +141,52 @@ This will update the trunk branch (e.g. `main`)
123141
with the latest changes from the upstream repository,
124142
and delete any local branches whose PRs have been merged.
125143

126-
## Importing pull requests
144+
## Importing open CRs
127145

128-
You can import an existing PR into git-spice
146+
You can import an existing open CR into git-spice
129147
by checking it out locally, tracking the branch with git-spice,
130148
and re-submitting it.
131149

132-
For example, if you have the GitHub CLI installed:
150+
For example:
133151

134-
```freeze language="terminal"
135-
{gray}# Check out the PR locally{reset}
136-
{green}${reset} gh pr checkout 359
152+
=== "<!-- gs:github -->"
137153

138-
{gray}# Track it with git-spice{reset}
139-
{green}${reset} gs branch track
154+
```freeze language="terminal"
155+
{gray}# Check out the PR locally{reset}
156+
{green}${reset} gh pr checkout 359
140157

141-
{gray}# Re-submit it{reset}
142-
{green}${reset} gs branch submit
143-
{green}INF{reset} comment-recovery: Found existing CR #359
144-
{green}INF{reset} CR #359 is up-to-date: https://github.com/abhinav/git-spice/pull/359
145-
```
158+
{gray}# Track it with git-spice{reset}
159+
{green}${reset} gs branch track
160+
161+
{gray}# Re-submit it{reset}
162+
{green}${reset} gs branch submit
163+
{green}INF{reset} comment-recovery: Found existing CR #359
164+
{green}INF{reset} CR #359 is up-to-date: https://github.com/abhinav/git-spice/pull/359
165+
```
166+
167+
=== "<!-- gs:gitlab -->"
168+
169+
```freeze language="terminal"
170+
{gray}# Check out the MR locally{reset}
171+
{green}${reset} glab mr checkout 8
172+
173+
{gray}# Track it with git-spice{reset}
174+
{green}${reset} gs branch track
175+
176+
{gray}# Re-submit it{reset}
177+
{green}${reset} gs branch submit
178+
{green}INF{reset} reticulating-splines: Found existing CR !8
179+
{green}INF{reset} CR !8 is up-to-date: https://gitlab.com/abg/test-repo/-/merge_requests/8
180+
```
146181

147182
!!! important
148183

149184
For this to work, the following MUST all be true:
150185

151-
- The PR is pushed to a branch in the upstream repository
186+
- The CR is pushed to a branch in the upstream repository
152187
- The local branch name exactly matches the upstream branch name
153188

154-
This will work even for PRs that were not created by git-spice,
189+
This will work even for CRs that were not created by git-spice,
155190
or authored by someone else, as long as the above conditions are met.
156191

157192
In <!-- gs:version v0.5.0 --> or newer,

0 commit comments

Comments
 (0)