@@ -271,7 +271,7 @@ modified each line. Incredibly useful for reproducibility.
271
271
272
272
## Exercise
273
273
274
- :::::{exercise} Exercise: Explore basic archaeology commands (20 min)
274
+ ::::::: {exercise} Exercise: Explore basic archaeology commands (20 min)
275
275
Let us explore the value of these commands in an exercise. Future
276
276
exercises do not depend on this, so it is OK if you do not complete
277
277
it fully.
@@ -376,43 +376,64 @@ modified each line. Incredibly useful for reproducibility.
376
376
able to browse and use the code as it was back then.
377
377
1. How would you bring the code to the version of the code right before that line was last modified?
378
378
379
- ::::{solution}
380
- We provide here a solution for the command line but we also encourage you to
381
- try to solve this in the browser.
382
-
383
- 1. We use `git grep`:
384
- ```console
385
- $ git grep "Logic error in degree_correlation"
386
- ```
387
- This gives the output:
388
- ```
389
- networkx/algorithms/threshold.py: print("Logic error in degree_correlation", i, rdi)
390
- ```
391
- Maybe you also want to know the line number:
392
- ```console
393
- $ git grep -n "Logic error in degree_correlation"
394
- ```
395
- 2. We use `git annotate`:
396
- ```console
397
- $ git annotate networkx/algorithms/threshold.py
398
- ```
399
- Then search for "Logic error" by typing "/Logic error" followed by Enter.
400
- The last commit that modified it was `90544b4fa` (unless that line changed since).
401
- 3. We use `git show`:
402
- ```console
403
- $ git show 90544b4fa
404
- ```
405
- 4. Create a branch pointing to that commit (here we called the branch "past-code"):
406
- ```console
407
- $ git branch past-code 90544b4fa
408
- ```
409
- 5. This is a compact way to access the first parent of `90544b4fa` (here we
410
- called the branch "just-before"):
411
- ```console
412
- $ git switch --create just-before 90544b4fa~1
413
- ```
414
- ::::
415
- :::::
379
+ ::::::{solution}
380
+
381
+ :::::{tabs}
382
+ ::::{group-tab} Command line
383
+ 1. We use `git grep`:
384
+ ```console
385
+ $ git grep "Logic error in degree_correlation"
386
+ ```
387
+ This gives the output:
388
+ ```
389
+ networkx/algorithms/threshold.py: print("Logic error in degree_correlation", i, rdi)
390
+ ```
391
+ Maybe you also want to know the line number:
392
+ ```console
393
+ $ git grep -n "Logic error in degree_correlation"
394
+ ```
395
+ 2. We use `git annotate`:
396
+ ```console
397
+ $ git annotate networkx/algorithms/threshold.py
398
+ ```
399
+ Then search for "Logic error" by typing "/Logic error" followed by Enter.
400
+ The last commit that modified it was `90544b4fa` (unless that line changed since).
401
+ 3. We use `git show`:
402
+ ```console
403
+ $ git show 90544b4fa
404
+ ```
405
+ 4. Create a branch pointing to that commit (here we called the branch "past-code"):
406
+ ```console
407
+ $ git branch past-code 90544b4fa
408
+ ```
409
+ 5. This is a compact way to access the first parent of `90544b4fa` (here we
410
+ called the branch "just-before"):
411
+ ```console
412
+ $ git switch --create just-before 90544b4fa~1
413
+ ```
414
+ ::::
415
+
416
+ ::::{group-tab} GitHub
417
+ 1. On top of <https://github.com/networkx/networkx> click on the
418
+ magnifying glass and search for "Logic error in degree_correlation".
419
+ This tells us that the file `networkx/algorithms/threshold.py`
420
+ contains this line and you can click on the file.
421
+ This brings you to <https://github.com/networkx/networkx/blob/409979eff35f02eff54f4eea3731736bd431dc2e/networkx/algorithms/threshold.py#L550>.
422
+ 2. Click on the "Blame" button. Left next to the highlighted line you see
423
+ the commit which modified it last.
424
+ 3. You can click on the commit (open in new browser tab) which brings you
425
+ to <https://github.com/networkx/networkx/commit/90544b4fa5a7397a86e69ebf5778f4a0f6eafe1e>.
426
+ 4. Let's skip creating the branch on GitHub. Instead, we can browse the
427
+ project at this version:
428
+ <https://github.com/networkx/networkx/tree/90544b4>.
429
+ 5. Go back to the "Blame" view for the file `networkx/algorithms/threshold.py`:
430
+ <https://github.com/networkx/networkx/blame/409979eff35f02eff54f4eea3731736bd431dc2e/networkx/algorithms/threshold.py#L550>.
431
+ Navigate to the symbol "Blame prior to change ..." which you find next to the commit message that modified this line.
432
+ ::::
433
+ :::::
434
+
435
+ ::::::
436
+ :::::::
416
437
417
438
---
418
439
0 commit comments