Skip to content

Commit c4bf64c

Browse files
committed
Merge wiki
This merges the pages from the wiki, they will be subsequently transformed into `.html` pages. The reason for the migration away from the wiki is that the wiki can only be edited by people with `push` permissions, to combat spam. But GitGitGadget's home page can be edited via PRs. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2 parents 91236bb + 365adcd commit c4bf64c

File tree

3 files changed

+173
-0
lines changed

3 files changed

+173
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# How does GitGitGadget process user comments on PRs?
2+
3+
GitGitGadget is implemented as a GitHub App (with the very imaginative name ["GitGitGadget"](https://github.com/apps/gitgitgadget)), which means that a webhook is called on certain events, such as new PR comments on PRs (e.g. `issue_comment`).
4+
5+
In GitGitGadget's case, this webhook is implemented as an Azure Function: https://github.com/gitgitgadget/gitgitgadget/tree/master/azure-function
6+
7+
Apart from validating that the payload really originated from GitHub, the Azure Function performs a rudimentary check whether the comment (if it was triggered by a comment) contains a command that GitGitGadget should act on, and depending on that check triggers the Azure Pipeline [GitGitGadget PR Handler](https://dev.azure.com/gitgitgadget/git/_build?definitionId=3).
8+
9+
The `push` event (and also the `pull_request` event) is not actually handled by the Azure Function. It is handled via the Azure Pipeline being configured as "Pull request validation". That also allows it to be shown in the Checks tab of the PR.
10+
11+
You can see the difference on [the summary page of the GitGitGadget PR Handler pipeline](https://dev.azure.com/gitgitgadget/git/_build?definitionId=3): the `push`-triggered builds are labeled as "Pull request build", and the `issue_comment` ones as "Manual build" (because they are triggered using a Personal Access Token, also known as "PAT").
12+
13+
Depending how the Azure Pipeline was triggered, it calls [`misc-helper.ts`](https://github.com/gitgitgadget/gitgitgadget/blob/master/script/misc-helper.ts) with the `handle-pr-comment` or with the `handle-pr-push` parameter, respectively. More precisely, the pipeline has 4 steps:
14+
15+
1. Use Node 10.x
16+
2. Pull GitGitGadget, run npm, essentially:
17+
```sh
18+
test -d .git || git init || exit 1
19+
20+
git rev-parse HEAD >.git/PRE_FETCH_HEAD &&
21+
git fetch https://github.com/gitgitgadget/gitgitgadget master ||
22+
exit 1
23+
24+
[... commented-out dirty tricks to use PRs' patches early ...]
25+
git reset --hard FETCH_HEAD ||
26+
exit 1
27+
28+
# If nothing was pulled, we already built it
29+
test "$(git rev-parse HEAD)" != "$(cat .git/PRE_FETCH_HEAD)" ||
30+
exit 0
31+
32+
npm install &&
33+
npm run build ||
34+
exit 1
35+
```
36+
3. Obtain GitHub Token:
37+
```sh
38+
GIT_CONFIG_PARAMETERS="$GIT_CONFIG_PARAMETERS $EXTRA_CONFIG"
39+
node build/script/misc-helper.js set-app-token &&
40+
git config gitgitgadget.publishRemote \
41+
https://x-access-token:$(git config gitgitgadget.githubToken)@github.com/gitgitgadget/git
42+
```
43+
(The `EXTRA_CONFIG` is necessary because it contains a value that is configured via a secret pipeline variable.)
44+
4. Handle PR (Comment or Push):
45+
```sh
46+
GIT_CONFIG_PARAMETERS="$GIT_CONFIG_PARAMETERS $EXTRA_CONFIG"
47+
set -x
48+
if test "$(pr.comment.id)" -lt 0
49+
then
50+
case "$BUILD_SOURCEBRANCH" in
51+
refs/pull/[1-9]*/head|refs/pull/[1-9]*/merge)
52+
branchname=${BUILD_SOURCEBRANCH#refs/pull/}
53+
prnumber=${branchname%/*}
54+
;;
55+
*) echo "Invalid source branch: $BUILD_SOURCEBRANCH">&2; exit 1;;
56+
esac
57+
node build/script/misc-helper.js handle-pr-push "$prnumber"
58+
else
59+
node build/script/misc-helper.js handle-pr-comment "$(pr.comment.id)"
60+
fi
61+
```
62+
(The `pr.comment.id` pipeline variable is set when queuing the build via the Azure Function that is registered as a webhook, that's how we can discern between this mode vs push.)
63+
64+
The pipeline variable `GIT_CONFIG_PARAMETERS` (which is pre-set as an environment variable in the scripts, interpreted by Git in the same way as `git -c <key>=<value>` would be) is defined as `'user.name=GitGitGadget' 'user.email=gitgitgadget@gmail.com' 'gitgitgadget.workDir=$(Agent.HomeDirectory)/../git-worktree'`, i.e. it configures GitGitGadget as committer and it asks GitGitGadget to fetch the commits and notes to the directory`git-worktree/` that is located next to the Azure Pipeline build agent's own directory, which assumes that the agent is running in a suitable VM and its files are installed into the home directory of the account running the agent.
65+
66+
Ideally, this definition (even if it is very small compared to other pipeline definitions I maintain) would be tracked in a Git repository, but since we want this to be a CI build (so that it neatly shows those Checks in the PR page), the pipeline is already associated with gitgitgadget/git (even if the pipeline is configured not to "sync the source", i.e. it does not check out the code pushed to the PR), and we cannot simply add GitGitGadget's Azure Pipelines' definitions to `master` because that is mirrored verbatim from git/git.
67+
68+
# Mirroring replies from the Git mailing list to GitGitGadget's PRs
69+
70+
This is performed by the [Mirror Git List to GitGitGadget's PRs](https://dev.azure.com/gitgitgadget/git/_build?definitionId=5) pipeline. Its tasks look very similar to the ones of the GitGitGadget PR Handler pipeline described [above](#how-does-gitgitgadget-process-user-comments-on-prs), but it is triggered by updates to the `master` branch of the Git mailing list archive at https://public-inbox.org/git and calls `misc-helper.js handle-new-mails`instead of the `handle-pr-comment`/`handle-pr-push` commands.
71+
72+
# Update PR labels and mentioning when/where the patches were integrated
73+
74+
The PRs labels are updated, and the comments that document how the corresponding branch is called and when the patches were integrated and into which branch(es), and the PRs are closed when the patches hit `master` and/or `maint` by the [Update GitGitGadget's PRs](https://dev.azure.com/gitgitgadget/git/_build/index?definitionId=2) pipeline. Its tasks look very similar to the GitGitGadget PR Handler pipeline described [above](#how-does-gitgitgadget-process-user-comments-on-prs), but it is triggered by updates to the branches `pu`, `next`, `master` and `maint` at https://github.com/git/git, and it calls `misc-helper.ts update-open-prs`, `misc-helper.ts update-commit-mappings` and `misc-helper.ts handle-open-prs` instead of the `handle-pr-comment`/`handle-pr-push` commands.
75+
76+
# Keeping https://github.com/gitgitgadget/git up to date
77+
78+
The repository gitgitgadget/git is kept up to date by two Azure Pipelines: [Synchronize gitster.git to GitGitGadget](https://dev.azure.com/gitgitgadget/git/_build?definitionId=8) and [Synchronize git.git to GitGitGadget](https://dev.azure.com/gitgitgadget/git/_build?definitionId=7).
79+
80+
## Why synchronize both git/git _and_ gitster/git?
81+
82+
### Background
83+
84+
The existence of the `git/git` -> `gitgitgadget/git` pipeline is probably obvious.
85+
86+
The `gitster/git` repository contains the individual branches for code contributions, and the first reason why the corresponding pipeline was added is that `pu` had test failures all the time without any actionable information: it has been always unclear _which_ of those patch series that made it into `pu` was responsible for the test failures. Now with the individual branches being mirrored into `gitgitgadget/git`, and obviously triggering [CI builds](https://dev.azure.com/gitgitgadget/git/_build?definitionId=4), it is a lot easier to find the culprits.
87+
88+
Of course, from time to time the `pu` failures are caused by unfortunate interactions of separate patch series' changes, in which case the CI builds of the individual branches may very well succeed but `pu` still causes failures, which is a very useful piece of information in and of itself.
89+
90+
A secondary benefit of mirroring the `gitster/git` branches is that PRs at `gitgitgadget/git` can target more fine-grained base commits. I use this a lot, e.g. in my six "built-in add -i/-p" patch series which build on top of each other.
91+
92+
While the pipeline that synchronizes with `gitster/git` is triggered by all updates to `refs/heads/*`, for technical reasons polling every 180 seconds, i.e. every three minutes, the pipeline that synchronizes with `git/git` is triggered immediately.
93+
94+
### What do the pipelines do, exactly?
95+
96+
The pipeline that mirrors gitster/git into gitgitgadget/git (the pipeline names cannot contain slashes, that's why the `/` was replaced by a `.`) has two tasks:
97+
98+
1. Synchronize branch:
99+
```bash
100+
case "$(Build.SourceBranch)" in
101+
refs/heads/*)
102+
refspec="+HEAD:$(Build.SourceBranch)"
103+
;;
104+
refs/tags/*)
105+
refspec="$(Build.SourceBranch)"
106+
;;
107+
*)
108+
echo "Cannot handle '$(Build.SourceBranch)'" >&2
109+
exit 1
110+
;;
111+
esac
112+
113+
git -c http."https://github.com/gitgitgadget/git".extraheader="Authorization: Basic $(gitgitgadget.push.token.base64)" \
114+
push https://github.com/gitgitgadget/git "$refspec"
115+
```
116+
2. Synchronize tags (if necessary):
117+
```bash
118+
die () {
119+
echo "$*" >&2
120+
exit 1
121+
}
122+
123+
for d in git gitgitgadget
124+
do
125+
git ls-remote --tags https://github.com/$d/git | grep -v '\^{}$' | sort >tags.$d ||
126+
die "Could not enumerate tags in $d"
127+
done
128+
129+
refspec="$(comm -23 tags.git tags.gitgitgadget | tr '\t' :)" ||
130+
die "Could figure out missing tags"
131+
132+
if test -z "$refspec"
133+
then
134+
echo "##vso[task.complete result=Skipped]No tags to synchronize!"
135+
else
136+
git -c http."https://github.com/gitgitgadget/git".extraheader="Authorization: Basic $(gitgitgadget.push.token.base64)" \
137+
push https://github.com/gitgitgadget/git $refspec
138+
fi
139+
```
140+
141+
That second task is necessary because there is currently no way to trigger non-YAML Azure Pipelines from tag updates. Of course this means that new tags are only synchronized together with branch updates, but in practice that's okay because the Git maintainer always pushes out the tags with corresponding branches.
142+
143+
This task mirrors tags from the git/git repository, even if the pipeline purports to mirror `gitster/git` to `gitgitgadget/git`; This is a deliberate decision, to make sure that we only mirror the "official tags" from the authoritative repository.
144+
145+
The two pipelines are identical except for these aspects:
146+
- The `gitster/git` repository contains substantially more branches. The only `git/git` branch that is missing from `gitster/git` is `todo`, which [we might parse at some stage to provided concise excerpts from the "What's cooking" mails](https://github.com/gitgitgadget/gitgitgadget/issues/152).
147+
- For technical reasons, the `git/git` pipeline does not need to poll.
148+
149+
### Git GUI's branches
150+
151+
As GitGitGadget can also be used to contribute Git GUI patches and patch series, there is also the [Synchronize git-gui.git (branches only) to GitGitGadget](https://dev.azure.com/gitgitgadget/git/_build?definitionId=10) pipeline. It mirrors the branches of Pratyush Yadav's repository (i.e. the current Git GUI maintainer's authoritative repository) into the `git-gui/*` namespace on `gitgitgadget/git`.

Home.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This is GitGitGadget, helping contributors to send patch series to the Git mailing list.
2+
3+
See [more details](https://gitgitgadget.github.io/) on the home page.

ReplyToThis.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
You most likely found this page because you contributed patches to the Git mailing list via GitGitGadget, and a mail from the Git mailing list was mirrored to your Pull Request, and now you need to answer.
2+
3+
The easiest method (unless you are subscribed to the Git mailing list and saw the mail already) is to import the so-called "mbox" file. You can get that by following the "On the Git mailing list" link on the top of the mirrored mail and then downloading the "raw" version (you can do the same by appending `/raw` to the link).
4+
5+
This file now needs to be imported into your regular mail program.
6+
7+
## How to import an `mbox` file
8+
9+
### If your mail program stores mails in "maildir" format (Thunderbird, Mutt, Alpine, etc)
10+
11+
Simply copy the file to the `new` subfolder in your mailer's maildir folder.
12+
13+
### If you use webmail (GMail and friends)
14+
15+
You can use the command-line tool `curl` (provided that your version has IMAP support):
16+
17+
```sh
18+
curl -g --user "<email>:<password>" --url "imaps://imap.gmail.com/INBOX" -T /path/to/raw.txt
19+
```

0 commit comments

Comments
 (0)