@@ -3,21 +3,99 @@ title: Download Workflow
33parent : Architecture
44---
55
6- # Download Workflow
6+ ## General download sequence
7+
8+ Both hands-on and exercises are downloaded using the same ` gitmastery download ` command.
9+
10+ Hands-on will have the ` hp- ` prefix before the name of the hands-on.
11+
12+ ``` mermaid
13+ flowchart
14+ a[gitmastery download] --> b[Check if prefixed with hp-]
15+ b -- prefixed with hp- --> c[Download hands-on]
16+ b -- else --> d[Download exercise]
17+ ```
18+
19+ Refer to the following sections for the specific download sequences.
20+
21+ ## Hands-on download
22+
23+ These are handled within the app's ` download.py ` command, through the ` download_hands_on ` function.
724
825``` mermaid
926flowchart
10- a[Download exercise ] --> b[Create exercise folder]
11- b --> c[Download base files to exercise root ]
12- c --> d[Check Git if toggled ]
13- d --> e[Check Github if toggled ]
14- e -- local -- > f[Create local repo folder with repo_name ]
15- e -- remote --> g[Fork repository if toggled]
16- g --> h[Clone repository with repo_name ]
17- f --> i[Download resources ]
18- h --> i
19- i --> j[Create initial commit if init toggled]
20- j --> k[Execute download function]
27+ a[Download hands-on ] --> b[Check that hands-on exists in the hands_on/ folder]
28+ b -- does not exist -- > c[Error and stop the download ]
29+ b -- else -- > d[Check if hands-on already exists ]
30+ d -- yes -- > e[Delete hands-on and re-download ]
31+ e --> f[" Create hands-on folder (hp-<hands-on name>)" ]
32+ d -- no --> f
33+ f --> g[Change directory to hands-on directory ]
34+ g --> h[Load hands-on file as namespace to extract variables and functions ]
35+ h --> i[Check Git if toggled]
36+ i --> j[Check Github if toggled]
37+ j --> k[Execute the download function in the hands-on file ]
2138```
2239
40+ ## Exercise download
41+
42+ These are handled within the app's ` download.py ` command, through the ` download_exercise ` function.
43+
44+ ``` mermaid
45+ flowchart
46+ A[Check if exercise exists] --> B{Exercise exists?}
47+ B -- No --> C[Error and stop the download]
48+ B -- Yes --> D[Check if exercise folder already exists]
49+ D -- Yes --> E[Delete existing folder]
50+ D -- No --> F[Create exercise folder]
51+ E --> F
52+ F --> G[Change directory to exercise folder]
53+ G --> H["Download base files (.gitmastery-exercise.json, README.md)"]
54+ H --> I[Read config file]
55+
56+ I --> J{Requires Git?}
57+ J -- Yes --> K[Check Git setup]
58+ K -- Not setup --> L[Rollback, remove folder, stop download]
59+ J -- No --> M[Proceed]
60+
61+ M --> N{Requires Github?}
62+ N -- Yes --> O[Check Github setup]
63+ O -- Not setup --> P[Rollback, remove folder, stop download]
64+ N -- No --> Q[Proceed]
65+
66+ Q --> R{Config has base files?}
67+ R -- Yes --> S[Download additional resources]
68+ R -- No --> T[Skip resource download]
69+
70+ S --> U{"Repo type != 'ignore'?"}
71+ T --> U
72+ U -- Yes --> V[Setup exercise folder]
73+ U -- No --> Z1[Save config with timestamp<br/>Print cd into exercise folder]
74+
75+ %% setup_exercise_folder details
76+ V --> V1[Save metadata to .gitmastery-exercise.json]
77+ V1 --> V2{Repo type: local or remote?}
78+ V2 -- Local --> V3[Create local folder]
79+ V2 -- Remote --> V4[Retrieve from GitHub]
80+ V4 --> V5{Fork required?}
81+ V5 -- Yes --> V6[Check/delete existing fork<br/>Create new fork<br/>Clone fork]
82+ V5 -- No --> V7[Clone repository]
83+ V3 --> V8[cd into repo folder]
84+ V6 --> V8
85+ V7 --> V8
86+ V8 --> V9[Fetch resources via download.py]
87+ V9 --> V10{Resources exist?}
88+ V10 -- Yes --> V11[Download and save resources]
89+ V10 -- No --> V12[Skip resource download]
90+ V11 --> V13{Repo init enabled?}
91+ V12 --> V13
92+ V13 -- Yes --> V14[Initialize repo<br/>Commit initial state]
93+ V13 -- No --> V15[Skip repo init]
94+ V14 --> V16["Execute setup() from download.py"]
95+ V15 --> V16
96+ V16 --> V17[Print cd into exercise repo folder]
97+
98+ Z1 --> Z2[Download complete]
99+ V17 --> Z2
100+ ```
23101
0 commit comments