Skip to content

Commit 2744e64

Browse files
authored
Merge pull request #514 from avancra/add-RStudio-browsing
Add Rstudio tab to the Copy and browse episode - Fixes #498
2 parents a6608fa + f8592b0 commit 2744e64

8 files changed

Lines changed: 95 additions & 13 deletions

File tree

.github/workflows/sphinx.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
name: sphinx
11-
on: [push, pull_request]
11+
on: [push, pull_request, workflow_dispatch]
1212

1313
env:
1414
DEFAULT_BRANCH: "main"
@@ -100,14 +100,15 @@ jobs:
100100
- name: Generate PDF
101101
if: ${{ env.GENERATE_PDF == 'true' }}
102102
run: |
103-
pip install https://github.com/rkdarst/sphinx_pyppeteer_builder/archive/refs/heads/main.zip
103+
#pip install https://github.com/rkdarst/sphinx_pyppeteer_builder/archive/refs/heads/main.zip
104+
pip install sphinx_pyppeteer_builder
104105
make pyppeteer
105106
mv _build/pyppeteer/*.pdf _build/dirhtml/${PDF_FILENAME}
106107
107108
# Stage all deployed assets in _gh-pages/ for simplicity, and to
108109
# prepare to do a multi-branch deployment.
109110
- name: Copy deployment data to _gh-pages/
110-
if: ${{ github.event_name == 'push' }}
111+
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
111112
run:
112113
rsync -a _build/dirhtml/ _gh-pages/
113114

@@ -116,21 +117,21 @@ jobs:
116117
# https://github.com/coderefinery/gh-pages-multibranch
117118
- name: gh-pages multibranch
118119
uses: coderefinery/gh-pages-multibranch@main
119-
if: ${{ github.event_name == 'push' && env.MULTIBRANCH == 'true' }}
120+
if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && env.MULTIBRANCH == 'true' }}
120121
with:
121122
directory: _gh-pages/
122123
default_branch: ${{ env.DEFAULT_BRANCH }}
123124
publish_branch: gh-pages
124125

125126
# Add the .nojekyll file
126127
- name: nojekyll
127-
if: ${{ github.event_name == 'push' }}
128+
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
128129
run: |
129130
touch _gh-pages/.nojekyll
130131
131132
# Save artifact for the next step.
132133
- uses: actions/upload-artifact@v4
133-
if: ${{ github.event_name == 'push' }}
134+
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
134135
with:
135136
name: gh-pages-build
136137
path: _gh-pages/
@@ -142,13 +143,13 @@ jobs:
142143
runs-on: ubuntu-latest
143144
needs: build
144145
# This if can't use the env context - find better way later.
145-
if: ${{ github.event_name == 'push' }}
146+
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
146147
permissions:
147148
contents: write
148149

149150
steps:
150151
- uses: actions/download-artifact@v4
151-
if: ${{ github.event_name == 'push' && ( env.MULTIBRANCH == 'true' || github.ref == format('refs/heads/{0}', env.DEFAULT_BRANCH )) }}
152+
if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && ( env.MULTIBRANCH == 'true' || github.ref == format('refs/heads/{0}', env.DEFAULT_BRANCH )) }}
152153
with:
153154
name: gh-pages-build
154155
path: _gh-pages/
@@ -162,7 +163,7 @@ jobs:
162163
# https://github.com/peaceiris/actions-gh-pages
163164
- name: Deploy
164165
uses: peaceiris/actions-gh-pages@v3
165-
if: ${{ github.event_name == 'push' && ( env.MULTIBRANCH == 'true' || github.ref == format('refs/heads/{0}', env.DEFAULT_BRANCH )) }}
166+
if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && ( env.MULTIBRANCH == 'true' || github.ref == format('refs/heads/{0}', env.DEFAULT_BRANCH )) }}
166167
with:
167168
publish_branch: gh-pages
168169
github_token: ${{ secrets.GITHUB_TOKEN }}

content/browsing.md

Lines changed: 85 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,18 @@ own changes in the next episode.
2424

2525
## GitHub, VS Code, Command line, and more
2626

27-
We offer **three different paths** for this exercise:
27+
We offer **four different paths** for this exercise:
2828
- **GitHub** (this is the one we will demonstrate on day 1)
2929
- **VS Code** (if you prefer to follow along using an editor; we will
3030
return to this on day 2)
31+
- **RStudio** (if you prefer to follow along using an editor; we will
32+
return to this on day 2)
3133
- **Command line** (for people comfortable with the command line; you
3234
will see more of this on day 2)
3335

34-
In the future we'll add more paths, for example Jupyter and RStudio
36+
In the future we'll add more paths, for example Jupyter
3537
([contributions welcome!](https://github.com/coderefinery/git-intro/issues/458)).
3638

37-
3839
## Creating a copy of the repository by "forking"
3940

4041
A {term}`repository` is a collection of files in one directory tracked
@@ -66,7 +67,7 @@ become important later, when we make our own changes.
6667
1. You should shortly be redirected to your copy of the repository
6768
**USER/recipe-book**.
6869

69-
At all times you should be aware of if you looking at *your* repository
70+
At all times you should be aware of if you are looking at *your* repository
7071
or the *CodeRefinery {term}`upstream`* repository.
7172
* Your repository: https://github.com/**USER**/recipe-book
7273
* CodeRefinery upstream repository: https://github.com/**cr-workshop-exercises**/recipe-book
@@ -115,6 +116,22 @@ need to have forked the repository as described above.
115116
HTTPS, depending on your setup.
116117
1. Change to that directory: `cd recipe-book`
117118
::::
119+
120+
::::{group-tab} RStudio
121+
You need to have forked the repository as described above.
122+
123+
We need to start by making a copy of this repository locally.
124+
125+
1. Start RStudio.
126+
1. Go to "File" → "New Project..."
127+
1. Choose "Version Control", and then "Git"
128+
1. In the "Repository URL" field, paste in this URL: `https://github.com/USER/recipe-book`, where
129+
`USER` is your username. You can copy this from the browser.
130+
1. You can change the "Project directory name" if you want but that is not mandatory.
131+
By default, it will use the repository name from the URL.
132+
1. Click "Create Project"
133+
::::
134+
118135
:::::
119136

120137

@@ -204,6 +221,16 @@ $ git log --oneline
204221
```
205222
::::
206223

224+
::::{group-tab} RStudio
225+
This can be done from "History", in the top right panel of explorer. This will open a pop-up window
226+
from which you can explore the history of commits.
227+
:::{figure} img/browsing/history_RStudio.png
228+
:alt: Screenshot of RStudio of where to find the commit history
229+
:width: 100%
230+
:class: with-border
231+
:::
232+
::::
233+
207234
:::::
208235

209236

@@ -240,8 +267,20 @@ $ git graph
240267
If not, you can use the basic command:
241268
```console
242269
$ git log --graph --oneline --decorate --all
270+
```
243271
::::
244272

273+
::::{group-tab} RStudio
274+
This can be viewed in the same "History" tab that we just looked at. The branch network can be seen on the left of
275+
the commit list, and individual commits can be clicked to see the person who committed and what changes they did.
276+
277+
:::{figure} img/browsing/network_RStudio.png
278+
:alt: Screenshot of RStudio of where to find the commit history
279+
:width:100%
280+
:class: with-border
281+
:::
282+
283+
::::
245284
:::::
246285

247286

@@ -276,6 +315,25 @@ $ git log sides/guacamole.md
276315
```
277316
::::
278317

318+
::::{group-tab} RStudio
319+
Open the file in the main editor window, and navigate to the "Version control" menu (Git icon in the toolbar right
320+
below the main menu bar), then select "Log of guacamole.md"
321+
:::{figure} img/browsing/file-history_RStudio_menu.png
322+
:alt: Screenshot of RStudio of where to find the file history
323+
:width: 100%
324+
:class: with-border
325+
:::
326+
327+
This will open a pop-up window showing all commits that modified the "Guacamole.md" file.
328+
329+
:::{figure} img/browsing/file-history_RStudio_view.png
330+
:alt: Screenshot of RStudio showing history of the guacamole.md file
331+
:width: 100%
332+
:class: with-border
333+
:::
334+
335+
::::
336+
279337
:::::
280338

281339

@@ -325,6 +383,18 @@ $ git grep -i salt # case insensitive
325383
```
326384
::::
327385

386+
::::{group-tab} RStudio
387+
Go to Edit → Find in Files... (ctrl+shift+F) and type salt in the Find field. It will by default search for salt in
388+
all files in the recipe-book directory. Press Find button at the bottom of the pop-up window. It will show all
389+
occurrences in every file in a Find in Files tab in the Console panel.
390+
391+
:::{figure} img/browsing/search_RStudio.png
392+
:alt: Screenshot of the Find in Files tab in RStudio showing all "salt" occurrences in every file
393+
:width: 100%
394+
:class: with-border
395+
:::
396+
::::
397+
328398
:::::
329399

330400

@@ -359,6 +429,17 @@ $ git blame sides/guacamole.md
359429
```
360430
::::
361431

432+
::::{group-tab} RStudio
433+
Open the file in the main editor window, and navigate to the "Version control" menu (Git icon in the toolbar right
434+
below the main menu bar), then select "Blame "guacamole.md" on GitHub". This will open a GitHub page in your
435+
web-browser with the same view as shown in the GitHub tab.
436+
:::{figure} img/browsing/annotate_RStudio.png
437+
:alt: Screenshot of RStudio of where to find the file history
438+
:width: 100%
439+
:class: with-border
440+
:::
441+
::::
442+
362443
:::::
363444

364445

105 KB
Loading
97.1 KB
Loading
63.1 KB
Loading
146 KB
Loading
130 KB
Loading
98.5 KB
Loading

0 commit comments

Comments
 (0)