Skip to content
100 changes: 93 additions & 7 deletions content/archaeology.md
Comment thread
frankier marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
:::


## Command line, GitHub, and VS Code
## Command line, GitHub/GitLab, and VS Code

As usual, we offer ways to do this with the command line, VS Code, and
GitHub.
GitHub/GitLab.

* **Command line** is most powerful and relatively easy with this.
You may also use it along with other things. If you haven't tried
it yet, we'd recommend you to give it a try.
* The **GitHub** web interface allows many things to be done, but not
* The **GitHub/GitLab** web interface allows many things to be done, but not
everything.
* **VS Code** allows some of these, but for some it's easier to open
the VS Code terminal and run Git there.
Expand All @@ -38,10 +38,10 @@ Later we will practice these in an archaeology exercise (below).
### Warm-up: ["Git History" browser](https://githistory.xyz/)

As a warm-up we can try the ["Git History" browser](https://githistory.xyz/)
on the README.rst file of the [networkx](https://github.com/networkx/networkx) repository:
on the README.rst file of the [networkx](https://github.com/networkx/networkx) repository (or the [ASE](https://gitlab.com/ase/ase/) repository on GitLab):

- Visit and browse <https://github.githistory.xyz/networkx/networkx/blob/main/README.rst> (use left/right keys).
- You can try this on some of your GitHub repositories, too!
- Visit and browse <https://github.githistory.xyz/networkx/networkx/blob/main/README.rst> (GitHub) or <https://gitlab.githistory.xyz/ase/ase/blob/master/README.rst> (GitLab). Use left/right keys to move through the history of the README.
- You can try this on some of your GitHub/GitLab repositories, too!


### Searching text patterns in the repository
Expand Down Expand Up @@ -90,6 +90,28 @@ some error message printed.
```
::::

::::{group-tab} GitLab
We can see a similar example but with the ASE repository instead of NetworkX at [https://gitlab.com/search?...](https://gitlab.com/search?search=fixme&nav_source=navbar&project_id=470007&group_id=293845&search_code=true&repository_ref=master).

This search result page is accessible by first going to the [ASE repository page](https://gitlab.com/ase/ase) and then using the search bar at the top of the page:

:::{figure} img/gitlab/archaeology-search-start.png
:alt: Searching for “fixme” in the ASE GitLab repository.
:width: 100%
:class: with-border

Searching for "fixme" in the ASE GitLab repository.
:::

:::{figure} img/gitlab/archaeology-search-results.png
:alt: Results for “fixme” in the ASE GitLab repository.
:width: 100%
:class: with-border

Results for "fixme" in the ASE GitLab repository.
:::
::::

::::{group-tab} VS Code
Our example repository is <https://github.com/networkx/networkx>.
From a new VS Code window, select "Clone Git repository" and enter
Expand Down Expand Up @@ -149,6 +171,18 @@ some error message printed.
```
::::

::::{group-tab} GitLab
We can look at another ASE example <https://gitlab.com/ase/ase/-/commit/fd0bd0df7aabe7977d48d72824b846535d15592a> (this commit switches some lines from using string to using Python's pathlib)

:::{figure} img/gitlab/archaeology-show.png
:alt: Inspecting an individual commit on GitLab.
:width: 100%
:class: with-border

Inspecting an individual commit on GitLab.
:::
::::

::::{group-tab} VS Code
We don't know of a built-in way to see every single Git commit in
order (extensions allow this). You can open the terminal and run
Expand Down Expand Up @@ -207,6 +241,19 @@ modified each line. Incredibly useful for reproducibility.
```
::::

::::{group-tab} GitLab
In the ASE project, this file:
<https://gitlab.com/ase/ase/-/blob/master/ase/geometry/geometry.py>

:::{figure} img/gitlab/archaeology-annotate.png
:alt: Opening the blame view for a file on GitLab.
:width: 100%
:class: with-border

Opening the blame view for a file on GitLab.
:::
::::

::::{group-tab} VS Code
It seems this needs an extension. We'd recommend trying the
command line method for now.
Expand Down Expand Up @@ -275,6 +322,20 @@ modified each line. Incredibly useful for reproducibility.
```
::::

::::{group-tab} GitLab
We can visit the commit again <https://gitlab.com/ase/ase/-/commit/fd0bd0df7aabe7977d48d72824b846535d15592a>

Once we are there we can "Browse files" at that point in history.

:::{figure} img/gitlab/archaeology-browse-files.png
:alt: Browsing the repository files at an earlier GitLab commit.
:width: 100%
:class: with-border

Browsing the repository files at an earlier GitLab commit.
:::
::::

::::{group-tab} VS Code
Switch to "Source Control", then the "..." menu, then "Branch", then "Create new branch from..." and now you can type a commit identifier (hash).

Expand Down Expand Up @@ -314,6 +375,10 @@ modified each line. Incredibly useful for reproducibility.
creating a new local repository.
::::

::::{group-tab} GitLab
No local repository is needed for this path; inspect <https://gitlab.com/obob/pymatreader> directly.
::::

::::{group-tab} VS Code
**Warning: many of these exercise tasks aren't possible in the VS Code interface without extensions. You can use VS Code to clone the project, but be prepared to start the terminal to do the main tasks.**

Expand Down Expand Up @@ -341,6 +406,10 @@ modified each line. Incredibly useful for reproducibility.
Nothing to clone. We will try to inspect the repository directly on GitHub.
::::

::::{group-tab} GitLab
Nothing to clone. We will try to inspect the repository directly on GitLab.
::::

::::{group-tab} VS Code
From a new VS Code window, select "Clone Git repository" and enter
that URL.
Expand Down Expand Up @@ -372,6 +441,10 @@ modified each line. Incredibly useful for reproducibility.
We can visit the version directly: <https://github.com/networkx/networkx/tree/networkx-2.6.3>
::::

::::{group-tab} GitLab
We can visit the version directly: <https://gitlab.com/ase/ase/-/tree/3.26.0?ref_type=tags> in this case **version 3.26.0**.
::::

::::{group-tab} VS Code
Switch to "Source Control", then the "..." menu, then "Branch", then "Create new branch from..." and select "networkx-2.6.3".
::::
Expand All @@ -387,7 +460,7 @@ modified each line. Incredibly useful for reproducibility.
:::::

Then using the above toolbox try to:
1. Find the code line which contains `"Logic error in degree_correlation"`.
1. Find the code line which contains `"Logic error in degree_correlation"`. (For GitLab/ASE find the code referred to by the comment `"Set the positions from the ones passed in"`.)
1. Find out when this line was last modified or added. Find the actual commit which modified that line.
1. Inspect the commit. What is the commit change? What is the commit metadata?
1. Create a branch pointing to the past when that commit was created to be
Expand Down Expand Up @@ -448,6 +521,19 @@ modified each line. Incredibly useful for reproducibility.
<https://github.com/networkx/networkx/blame/409979eff35f02eff54f4eea3731736bd431dc2e/networkx/algorithms/threshold.py#L550>.
Navigate to the symbol "Blame prior to change ..." which you find next to the commit message that modified this line.
::::

::::{group-tab} GitLab
1. Go to <https://gitlab.com/ase/ase/-/tree/3.26.0?ref_type=tags>, click on the search bar and search for "Set the positions from the ones passed in"
Clicking the line in the result brings you to <https://gitlab.com/ase/ase/-/blob/3.26.0/ase/filters.py#L436>
2. Click on the "Blame" button. Next to the line of code referred to by the comment you see the commit which modified it last.
3. You can click on the commit which brings you to <https://gitlab.com/ase/ase/-/commit/98513a30cad6cc067e47d97561b5e228ced4c96d>
4. Let's skip creating the branch on GitLab. Instead, we can browse the
project at this version:
<https://gitlab.com/ase/ase/-/tree/98513a30cad6cc067e47d97561b5e228ced4c96d>.
5. Go back to the "Blame" view for the file `ase/filters.py`:
<https://gitlab.com/ase/ase/-/blob/3.26.0/ase/filters.py?blame=1#L436>.
Navigate to the symbol "Blame prior to change ..." which you find next to the commit message that modified this line.
::::
:::::

::::::
Expand Down
Loading
Loading