Skip to content

Commit a417097

Browse files
authored
Merge pull request #39 from code4mathorg/StevenClontz/collaborating202412
* update pretext * remove liveshare section * accidental commits to main * warn branch issue must be resolved in a Codespace * add merge conflict section
2 parents 9eb5263 + c33e8c8 commit a417097

File tree

4 files changed

+101
-56
lines changed

4 files changed

+101
-56
lines changed

.devcontainer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
"name": "PreTeXt-Codespaces",
1616

1717
// This Docker image includes some LaTeX support, but is still not to large. Note that if you keep your codespace running, it will use up your GitHub free storage quota. Additional options are listed below.
18-
"image": "oscarlevin/pretext:small",
18+
// "image": "oscarlevin/pretext:small",
1919
// If you need to generate more complicated assets (such as sageplots) or use additional fonts when building to PDF, comment out the above line and uncomment the following line.
20-
// "image": "oscarlevin/pretext:full",
20+
"image": "oscarlevin/pretext:full",
2121
// If you only intend to build for web and don't have any latex-image generated assets, you can use a smaller image:
2222
// "image": "oscarlevin/pretext:lite",
2323

.github/workflows/pretext-cli.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,21 @@ jobs:
2424
- name: install deps
2525
run: pip install -r requirements.txt
2626

27+
- name: install local ptx files
28+
run: pretext --version
29+
2730
- name: build deploy targets
28-
run: pretext build --deploys
31+
run: |
32+
version="$(pretext --version)"
33+
major="$(echo $version | cut -d '.' -f 1)"
34+
minor="$(echo $version | cut -d '.' -f 2)"
35+
if [ "$major" -ge 2 -a "$minor" -ge 5 ]; then
36+
echo "PreTeXt version is 2.5 or greater; using new build command"
37+
pretext build --deploys
38+
else
39+
echo "PreTeXt version is less than 2.5, using old build command"
40+
pretext build
41+
fi
2942
- name: stage deployment
3043
run: pretext deploy --stage-only
3144

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# <!-- Managed automatically by PreTeXt authoring tools -->
2-
pretext == 2.6.0
2+
pretext == 2.10.1

source/ch-collaboration.ptx

Lines changed: 84 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,11 @@
11
<?xml version='1.0' encoding='utf-8'?>
22
<chapter xml:id="ch-collaboration">
33
<title>Collaborating with Others</title>
4-
<section xml:id="sec-liveshare">
5-
<title>Live Share</title>
6-
<p>
7-
A nice feature of collaborative authoring tools such
8-
as Google Docs and Overleaf is the ability for several
9-
collaborators to edit the same file synchronously, with
10-
a feature set similar to <c>GitHub.dev</c>.
11-
</p>
12-
<p>
13-
Using the Extensions sidebar, search for and install
14-
Microsoft's <q>Live Share</q> extension. Once installed,
15-
you will have a <q>Live Share</q> option in your
16-
bottom toolar. Clicking it will automatically copy a URL
17-
ending in
18-
<c>https://.../join?[randomStringOfCharacters]</c>.
19-
If you share this URL with a colleague (or
20-
colleagues) you trust, they will be able to collaboratively
21-
edit your repository's text files with you via their web
22-
browser. When you commit your
23-
changes, they will be listed as co-authors of the commit.
24-
</p>
25-
<remark>
26-
<p>
27-
As of writing, my experience with LiveShare has been hit-or-miss,
28-
so I'll suggest another mechanism for live collaboration.
29-
Sometimes when I'm working on a Git repository
30-
with a collague on Zoom, I'll share my screen and give my collaborator
31-
control of my mouse and keyboard, or vice versa. Obviously
32-
you should only do this with a collaborator you trust, but it's
33-
a simple solution to quickly work together on the same repo!
34-
</p>
35-
</remark>
36-
</section>
374
<section xml:id="sec-collaborators-prs">
385
<title>Collaborators and Pull Requests</title>
396
<p>
40-
A particular downside of Live Share (<xref ref="sec-liveshare"/>)
41-
is that it requires
42-
the repository owner to create the Codespace and provision
43-
the Live Share session. As a result, there's no way for a
44-
collaborator to make a contribution via Live Share to a GitHub project
45-
without the active involvement of the repository owner.
46-
</p>
47-
<p>
48-
To address this, one solution is for the repository owner to
49-
add other GitHub users as collaborators.
7+
A direct way to allow multiple people you trust to work on the
8+
same repository is to add these GitHub users as collaborators.
509
</p>
5110
<definition xml:id="def-collabotors">
5211
<statement>
@@ -89,16 +48,19 @@ must name their distinct branches.
8948
</warning>
9049
<note>
9150
<p>
92-
One workflow to support multiple collaborators on the same
51+
Our recommendation to support multiple collaborators on the same
9352
repository is to <em>never directly commit to the <c>main</c> branch</em>,
9453
even if you're the owner.
9554
</p>
9655
<p>
9756
To commit to an alternative branch in <c>GitHub.dev</c> or Codespaces, select
9857
<c>main</c> in the bottom toolbar, then type the name of your new branch,
99-
and select <q>Create new branch</q>. The name of this branch could
100-
be topical, e.g. <c>add-derivative-chapter</c>, but it's also fine to
101-
pick some other unique identifier, e.g. <c>lastname-YYYY-MM-DD</c>.
58+
and select <q>Create new branch</q>. It's a good idea to name your
59+
branch in the form <c>UserName/short-description-of-topic</c>,
60+
or if you're unsure of the topic, you can just use the current
61+
date: <c>UserName/YYYYMMDD</c>. Note that prefixing with your
62+
<c>UserName</c> helps prevent two people from accidentally using the same
63+
branch name.
10264
</p>
10365
</note>
10466
<p>
@@ -203,21 +165,32 @@ using <c>main</c> as your <q>Branch name pattern</q>, and
203165
enabling required pull requests.
204166
</p>
205167
</note>
168+
</section>
169+
<section xml:id="sec-collaborators-undo-main">
170+
<title>Undoing accidental commmits to <c>main</c></title>
206171
<p>
207-
Finally, there's no button to push that will fix a commit
172+
Unfortunately, there's no button to push that will fix a commit
208173
made to the local copy of <c>main</c> accidentally, but there
209174
is a quick-enough fix nonetheless.
210175
</p>
176+
<warning>
177+
<p>
178+
This fix must be done in a Codespace,
179+
not GitHub.dev.
180+
</p>
181+
</warning>
211182
<note>
212183
<p>
213184
With branch protection <xref ref="note-branch-protection"/> enabled,
214185
if you accidentally make updates directly to your personal <c>main</c>
215186
branch, attempting to push these from a Codespace will result in
216-
tthe error message <c>Can't push refs to remote.
187+
the error message <c>Can't push refs to remote.
217188
Try running "Pull" first to integrate your changes.</c>
218189
</p>
219190
<p>
220-
To fix this, open the Terminal and type <xref ref="lst-branch-fix-1"/>,
191+
To fix this, open a Terminal
192+
(<xref ref="remark-terminal-shortcut"/>)
193+
and type <xref ref="lst-branch-fix-1"/>,
221194
changing <c>my-new-branch</c> to the branch name you want to create.
222195
Use <kbd>Enter</kbd> to execute the command.
223196
</p>
@@ -268,7 +241,7 @@ shared branches.
268241
</definition>
269242
<p>
270243
Managing contributions from forked repositories is done using the
271-
same workflow as I recomend for collaborating with trusted colleagues
244+
same workflow as we recommend for collaborating with trusted colleagues
272245
that you've given write access to your repository
273246
(<xref ref="sec-collaborators-prs"/>). The only difference
274247
is that an outside collaborator is creating branches and making commits
@@ -300,7 +273,66 @@ and open a pull request.
300273
<section xml:id="sec-conflicts">
301274
<title>Handling Merge Conflicts</title>
302275
<p>
303-
To come in a future revision of this handbook...
276+
Perhaps the most complicated scenario when collaborating
277+
on a Git repository is the dreaded <em>merge conflict</em>.
278+
</p>
279+
<definition xml:id="def-merge-conflict">
280+
<statement>
281+
<p>
282+
While Git is fairly good about merging together changes
283+
made by different contributors to different
284+
files within a project into a cohesive whole, a
285+
<term>merge conflict</term> can occur when two different
286+
contributors attempt to make changes to the same file
287+
(particularly, the same line) at the same time. When the
288+
second contributor opens a pull request, GitHub will warn
289+
about this conflict.
290+
</p>
291+
</statement>
292+
</definition>
293+
<p>
294+
Handling merge conflicts can be tricky!
295+
Git/GitHub have various tools to help you review and correct
296+
a merge conflict. If you're fortunate, you'll be able to resolve
297+
things on the pull request page: see
298+
<url href="https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-on-github">
299+
Resolving a merge conflict on GitHub
300+
</url> for full details.
301+
</p>
302+
<p>
303+
You'll be presented with files with some strange markers as in
304+
<xref ref="listing-merge-conflict"/>. The lines between
305+
<c>&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD</c> and
306+
<c>=======</c> were merged first, and the lines between
307+
<c>=======</c> and
308+
<c>&gt;&gt;&gt;&gt;&gt;&gt;&gt; branch-a</c> are the conflicting
309+
changes trying to be merged.
310+
</p>
311+
<listing xml:id="listing-merge-conflict">
312+
<program>
313+
<input>If you have questions, please
314+
&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD
315+
open an Issue
316+
=======
317+
ask them in Discussions.
318+
&gt;&gt;&gt;&gt;&gt;&gt;&gt; branch-a
319+
</input>
320+
</program>
321+
<caption>A merge conflict</caption>
322+
</listing>
323+
<p>
324+
You can then choose which change to retain, deleting all the
325+
extra <c>&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD</c>,
326+
<c>=======</c>, and
327+
<c>&gt;&gt;&gt;&gt;&gt;&gt;&gt; branch-a</c> lines.
328+
</p>
329+
<p>
330+
However, sometimes the merge conflict is too involved to be
331+
corrected using the web interface. In that situation, you will
332+
need to use a Codespace and follow the instructions at either
333+
<url href="https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line">Resolving a merge conflict using the command line</url>
334+
or
335+
<url href="https://code.visualstudio.com/docs/sourcecontrol/overview#_merge-conflicts">Using Git source control in VS Code | Merge conflicts</url>.
304336
</p>
305337
</section>
306338
</chapter>

0 commit comments

Comments
 (0)