Skip to content

Commit 7456102

Browse files
committed
add(docs): how to make QDT work with private git repositories
1 parent 453b0bb commit 7456102

File tree

5 files changed

+139
-7
lines changed

5 files changed

+139
-7
lines changed

.vscode/settings.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,9 @@
8080
"MD024": {
8181
"allow_different_nesting": true
8282
},
83-
}
83+
},
84+
"markdown-mermaid.languages": [
85+
"mermaid",
86+
"{mermaid}"
87+
]
8488
}

docs/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@
158158
}
159159

160160
# mermaid
161+
mermaid_d3_zoom = True
161162
mermaid_params = [
162163
"--theme",
163164
"forest",
@@ -166,7 +167,7 @@
166167
"--backgroundColor",
167168
"transparent",
168169
]
169-
mermaid_d3_zoom = True
170+
mermaid_version = "11.6.0"
170171

171172
# MyST Parser
172173
myst_enable_extensions = [
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# How to make QDT work with a private Git repository
2+
3+
For now, QDT does not support private Git repositories. It's a "to be funded" issue. If you are willing to see this feature land in the functional perimeter, don't hesitet to get in touch!
4+
5+
```{mermaid}
6+
---
7+
title: QDT workflow around a Git private forge (to be funded)
8+
---
9+
10+
flowchart LR
11+
A["QGIS/QDT admin"] <---> |"classic git workflow<br/>clone/pull & git push"| D(("Private Git repository<br/>i.e. git.myorg.com or on GitHub/Lab"))
12+
D --->|"QDT"| F["QGIS end-user<br/>profiles"]
13+
```
14+
15+
In the meanwhile, it's not a blocking lack, since QDT support local git repositories, i.e. stored on a network drive. Here comes a diagram illustrating the typical workflow used by most of end-users:
16+
17+
```{mermaid}
18+
---
19+
title: QDT workflow around a Git private forge (workaround)
20+
---
21+
22+
flowchart LR
23+
A["QGIS/QDT admin"] <---> |"classic git workflow<br/>clone/pull & git push"| D(("Private Git repository<br/>i.e. git.myorg.com or on GitHub/Lab"))
24+
D -->|"Pull<br/>(with deployment token)"| E[["Server on local network<br/>i.e. '//gis/software/qgis/qdt/profiles/'"]]
25+
E --->|"QDT"| F["QGIS end-user<br/>profiles"]
26+
```
27+
28+
To perform the intermediary git pull, it depends on the organization and GIS team habits. It can be performed manually through the command-line, with a GUI like the excellent [GitHub Desktop](https://github.com/apps/desktop) or with a script. We give below an example in PowerShell for Windows.
29+
30+
:::{info}
31+
This script is a sample and might not comply with your environment and/or IT policy. If you intend to use it in production, take time to review it before. If you improve or fix it, please share it.
32+
:::
33+
34+
```{eval-rst}
35+
.. literalinclude:: ../../scripts/qdt_clone_pull_profiles.ps1
36+
:language: powershell
37+
```

requirements/documentation.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
furo==2024.*
55
matplotlib>=3.8.2,<4
66
myst-parser[linkify]>=2,<5
7-
sphinx-argparse-cli>=1,<2
7+
sphinx-argparse-cli>=1.19,<2
88
sphinx-autobuild==2024.*
99
sphinx-copybutton<1
10-
sphinx-design>=0.5,<1
11-
sphinxcontrib-mermaid>=0.9,<2
12-
sphinxext-opengraph>=0.4,<1
13-
sphinx-sitemap>=2.4,<3
10+
sphinx-design>=0.6.1,<1
11+
sphinxcontrib-mermaid>=1,<2
12+
sphinxext-opengraph>=0.10,<1
13+
sphinx-sitemap>=2.6,<3
1414

1515
# -- 'HIDDEN' dependencies, used during CI
1616
# pip-licenses<5

scripts/qdt_clone_pull_profiles.ps1

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<#
2+
.SYNOPSIS
3+
Clone or update a Git repository to a network location specified through an environment variable.
4+
5+
.DESCRIPTION
6+
This script clones a remote Git repository to a directory specified by an environment variable.
7+
If the repository already exists locally, it performs a `git pull` to update it.
8+
9+
.LICENSE
10+
SPDX-License-Identifier: MIT
11+
#>
12+
13+
# -- VARIABLES --
14+
15+
# Default value if the environment variable is not set
16+
$basePath = if ($env:QDT_LOCAL_CLONE_PROFILES_PATH) { $env:QDT_LOCAL_CLONE_PROFILES_PATH } else { "$env:USERPROFILE\GitRepositories\qdt-qgis-profiles" };
17+
18+
# Remote Git repository URL
19+
$gitRepo = if ($env:QDT_REMOTE_PROFILES_GIT) { $env:QDT_REMOTE_PROFILES_GIT} else { "https://github.com/qgis-deployment/qgis-deployment-toolbelt-cli.git" };
20+
21+
# Target folder for the local repository
22+
$repoName = $gitRepo.Split("/")[-1].Replace(".git", "")
23+
$repoPath = Join-Path -Path $basePath -ChildPath $repoName
24+
25+
26+
# -- FUNCTIONS --
27+
function Test-GitInstalled {
28+
try {
29+
# Check if Git is installed and operational
30+
$gitVersion = git --version 2>&1
31+
if ($gitVersion -match "git version") {
32+
Write-Host "Git is installed: $gitVersion" -ForegroundColor Green
33+
return $true
34+
} else {
35+
Write-Host "Git is installed but not operational." -ForegroundColor Yellow
36+
return $false
37+
}
38+
} catch {
39+
Write-Host "Git is not installed or not found in the PATH." -ForegroundColor Red
40+
return $false
41+
}
42+
}
43+
44+
# -- MAIN --
45+
46+
# Check if Git is installed
47+
if (-not (Test-GitInstalled)) {
48+
Write-Error "Git is required for this script. Please install Git and ensure it is in your PATH."
49+
exit 1
50+
}
51+
52+
# Ensure the base directory exists, create it if necessary
53+
if (-not (Test-Path -Path $basePath)) {
54+
Write-Host "The directory '$basePath' does not exist. Creating it..."
55+
New-Item -ItemType Directory -Path $basePath | Out-Null
56+
}
57+
58+
59+
# Perform git clone or pull
60+
try {
61+
# Check if the repository already exists locally
62+
if (Test-Path -Path $repoPath) {
63+
Write-Host "Repository already exists locally at $repoPath. Performing 'git pull'..."
64+
65+
# Change to the repository directory
66+
Push-Location -Path $repoPath
67+
68+
# Pull the latest changes
69+
git fetch --all
70+
git reset --hard origin/main
71+
# $pullResult = git pull
72+
# Write-Host $pullResult
73+
74+
# Return to the original directory
75+
Pop-Location
76+
} else {
77+
Write-Host "No Git repository identified. Cloning remote repository to $repoPath..."
78+
79+
# Clone the repository
80+
git clone --config remote.origin.pushurl="DISABLED" `
81+
--depth=5 `
82+
$gitRepo `
83+
$repoPath
84+
}
85+
86+
Write-Host "Operation completed successfully!" -ForegroundColor Green
87+
} catch {
88+
Write-Error "An error occurred: $_"
89+
exit 1
90+
}

0 commit comments

Comments
 (0)