Skip to content

Commit 7a76fd3

Browse files
committed
init.sh: --gitlab also gives the project its description
1 parent f9c8eca commit 7a76fd3

2 files changed

Lines changed: 37 additions & 11 deletions

File tree

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,17 @@ default branch automatically, with no `main` stub to rename.
3232

3333
`--gitlab` does what is left of the project setup, and what the web UI would
3434
otherwise be needed for: it protects `develop` and `master` at the Maintainer
35-
level and copies the CI/CD variables the pipeline needs, the Gurobi WLS
36-
license and the deploy key, from an existing module (`--reference`, by default
37-
`smspp/binaryknapsackblock`). The variables are copied rather than kept here:
38-
they are secrets, and GitLab is the only place they belong to. It needs the
35+
level, gives the project the description of `--desc`, ending with a full stop
36+
as every other SMS++ module does, and copies the CI/CD variables the pipeline
37+
needs, the Gurobi WLS license and the deploy key, from an existing module
38+
(`--reference`, by default `smspp/binaryknapsackblock`). The variables are
39+
copied rather than kept here: they are secrets, and GitLab is the only place
40+
they belong to. It needs the
3941
[`glab`](https://gitlab.com/gitlab-org/cli) CLI, authenticated with a
4042
Maintainer of both projects. Given alone, in a checkout of an existing module,
41-
it does only this, which is how a module created before this option is brought
42-
up to standard:
43+
it does only this, taking the description already there when `--desc` is not
44+
given, which is how a module created before this option is brought up to
45+
standard:
4346

4447
```bash
4548
cd MyOlderBlock && /path/to/init.sh --gitlab

init.sh

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,14 @@ Options:
4343
default branch automatically, with no 'main' stub
4444
--gitlab after pushing, set the GitLab project up the way
4545
every SMS++ module is: protect 'develop' and
46-
'master' and copy the CI/CD variables (the Gurobi
47-
WLS license and the deploy key the CI needs) from
48-
--reference. Needs the 'glab' CLI, authenticated
49-
with a Maintainer of both projects. Given alone, in
50-
a checkout of an existing module, it does only this
46+
'master', give it the description of --desc, ending
47+
with a full stop as every other one does, and copy
48+
the CI/CD variables (the Gurobi WLS license and the
49+
deploy key the CI needs) from --reference. Needs the
50+
'glab' CLI, authenticated with a Maintainer of both
51+
projects. Given alone, in a checkout of an existing
52+
module, it does only this, taking the description
53+
already there if --desc is not given
5154
--reference <path> project the CI/CD variables are copied from
5255
(default: smspp/binaryknapsackblock)
5356
--umbrella <path> path to a checkout of the SMS++ umbrella project:
@@ -96,6 +99,26 @@ gitlab_setup() {
9699
fi
97100
done
98101

102+
# the description of the project, i.e. what the GitLab project page shows
103+
# under its name: it is the one of --desc, or the one already there when
104+
# this is run on an existing module, and it ends with a full stop, as the
105+
# description of every SMS++ module does
106+
local description
107+
description=${DESC:-$( glab api "projects/$encoded" |
108+
python3 -c 'import json,sys; print( json.load( sys.stdin )[ "description" ]
109+
or "" )' )}
110+
111+
if [ -n "$description" ]; then
112+
case "$description" in *. ) ;; * ) description="$description." ;; esac
113+
114+
if glab api --method PUT "projects/$encoded" \
115+
--raw-field "description=$description" >/dev/null 2>&1 ; then
116+
echo " described as \"$description\""
117+
else
118+
echo " could not set the description"
119+
fi
120+
fi
121+
99122
# the variables are read one at a time, so that no secret is ever written
100123
# anywhere but into the API call that carries it
101124
local keys key value protected masked raw

0 commit comments

Comments
 (0)