From d4ca4e3665ae55d200d59a8d12136f1e5c51a1c8 Mon Sep 17 00:00:00 2001
From: Tamas Gal <himself@tamasgal.com>
Date: Wed, 4 Dec 2024 12:28:02 +0100
Subject: [PATCH] Add post hook and clean up

---
 cookiecutter.json                              |  5 +++--
 hooks/post_gen_project.sh                      |  2 +-
 {{cookiecutter.project_slug}}/CONTRIBUTING.rst | 12 ++++++------
 {{cookiecutter.project_slug}}/README.rst       | 14 +++++++-------
 {{cookiecutter.project_slug}}/doc/index.rst    |  4 ++--
 {{cookiecutter.project_slug}}/setup.cfg        |  2 +-
 6 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/cookiecutter.json b/cookiecutter.json
index ce9a0e2..3871822 100755
--- a/cookiecutter.json
+++ b/cookiecutter.json
@@ -5,6 +5,7 @@
     "project_slug": "{{ cookiecutter.project_name.lower().replace(' ', '_') }}",
     "version": "0.1.0",
     "description": "The {{ cookiecutter.project_name }} project",
-    "gitlab_username": "{{cookiecutter.email.split('@')[0]}}",
-    "gitlab_repo_path": "https://git.km3net.de/{{ cookiecutter.gitlab_username + '/' + cookiecutter.project_slug }}"
+    "gitlab_username_or_group": "{{cookiecutter.email.split('@')[0]}}",
+    "gitlab_repo_url": "https://git.km3net.de/{{ cookiecutter.gitlab_username_or_group }}/{{ cookiecutter.project_slug }}",
+    "gitlab_pages_url": "https://{{ cookiecutter.gitlab_username_or_group }}.pages.km3net.de/{{ cookiecutter.project_slug }}"
 }
diff --git a/hooks/post_gen_project.sh b/hooks/post_gen_project.sh
index 075d3b9..7563198 100644
--- a/hooks/post_gen_project.sh
+++ b/hooks/post_gen_project.sh
@@ -3,7 +3,7 @@ git init --initial-branch=main
 git add .
 git commit -m 'Initial commit'
 git tag -a 'v{{cookiecutter.version}}' -m 'Release {{cookiecutter.version}}'
-git remote add origin git@git.km3net.de:{{cookiecutter.gitlab_username_or_group}}/{{cookiecutter.package_name}}.jl.git
+git remote add origin git@git.km3net.de:{{cookiecutter.gitlab_username_or_group}}/{{cookiecutter.project_name}}.git
 git push -u origin main
 git push --tags
 echo
diff --git a/{{cookiecutter.project_slug}}/CONTRIBUTING.rst b/{{cookiecutter.project_slug}}/CONTRIBUTING.rst
index 95fe7f6..c32ec75 100644
--- a/{{cookiecutter.project_slug}}/CONTRIBUTING.rst
+++ b/{{cookiecutter.project_slug}}/CONTRIBUTING.rst
@@ -6,9 +6,9 @@ need a new feature. Emails and private messages are not meant to communicate
 such things!
 
 Use the appropriate template and file a new issue here:
-{{cookiecutter.gitlab_repo_path}}/issues
+{{cookiecutter.gitlab_repo_url}}/issues
 
-You can browse all the issues here: {{cookiecutter.gitlab_repo_path}}/issues
+You can browse all the issues here: {{cookiecutter.gitlab_repo_url}}/issues
 
 Please follow the instructions in the templates to provide all the
 necessary information which will help other people to understand the
@@ -17,7 +17,7 @@ situation.
 Improve
 -------
 
-Check out our KanBan board {{cookiecutter.gitlab_repo_path}}/boards,
+Check out our KanBan board {{cookiecutter.gitlab_repo_url}}/boards,
 which shows all the open issues in three columns:
 
 - *discussion*: The issues which are yet to be discussed (e.g. not clear how to proceed)
@@ -39,7 +39,7 @@ a merge request, so we can review, discuss and add your contribution.
 Merge requests are automatically tested on our GitLab CI server and you
 don't have to do anything special.
 
-Go to {{cookiecutter.gitlab_repo_path}} and click on "Fork".
+Go to {{cookiecutter.gitlab_repo_url}} and click on "Fork".
 
 After that, you will have a full copy of the code with write access under an URL
 like this: ``https://git.km3net.de/YOUR_USERNAME/{{cookiecutter.project_slug}}``
@@ -55,7 +55,7 @@ Now you need to add a reference to the original repository, so you can sync your
 own fork with the original repository::
 
     cd {{cookiecutter.project_slug}}
-    git remote add upstream {{cookiecutter.gitlab_repo_path}}
+    git remote add upstream {{cookiecutter.gitlab_repo_url}}
 
 
 Keep your Fork Up to Date
@@ -153,7 +153,7 @@ matches the one we love and respect. We have a tool which makes it easy::
 Create a Merge Request (aka Pull Request)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-Go to {{cookiecutter.gitlab_repo_path}}/merge_requests/new and select your
+Go to {{cookiecutter.gitlab_repo_url}}/merge_requests/new and select your
 source branch, which contains the changes you want to be added to this project
 and select the ``master`` branch as target branch.
 
diff --git a/{{cookiecutter.project_slug}}/README.rst b/{{cookiecutter.project_slug}}/README.rst
index 94e95e6..b402dd0 100644
--- a/{{cookiecutter.project_slug}}/README.rst
+++ b/{{cookiecutter.project_slug}}/README.rst
@@ -1,14 +1,14 @@
 {{cookiecutter.description}}
 {% for i in range(cookiecutter.description|length) %}={% endfor %}
 
-.. image:: {{cookiecutter.gitlab_repo_path}}/badges/master/pipeline.svg
-    :target: {{cookiecutter.gitlab_repo_path}}/pipelines
+.. image:: {{cookiecutter.gitlab_repo_url}}/badges/master/pipeline.svg
+    :target: {{cookiecutter.gitlab_repo_url}}/pipelines
 
-.. image:: {{cookiecutter.gitlab_repo_path}}/badges/master/coverage.svg
-    :target: https://{{cookiecutter.gitlab_username}}.pages.km3net.de/{{cookiecutter.project_slug}}/coverage
+.. image:: {{cookiecutter.gitlab_repo_url}}/badges/master/coverage.svg
+    :target: https://{{cookiecutter.gitlab_username_or_group}}.pages.km3net.de/{{cookiecutter.project_slug}}/coverage
 
 .. image:: https://git.km3net.de/examples/km3badges/-/raw/master/docs-latest-brightgreen.svg
-    :target: https://{{cookiecutter.gitlab_username}}.pages.km3net.de/{{cookiecutter.project_slug}}
+    :target: https://{{cookiecutter.gitlab_username_or_group}}.pages.km3net.de/{{cookiecutter.project_slug}}
 
 
 Installation
@@ -17,14 +17,14 @@ Installation
 It is recommended to first create an isolated virtualenvironment to not interfere
 with other Python projects::
 
-  git clone {{cookiecutter.gitlab_repo_path}}
+  git clone {{cookiecutter.gitlab_repo_url}}
   cd {{cookiecutter.project_slug}}
   python3 -m venv venv
   . venv/bin/activate
 
 Install directly from the Git server via ``pip`` (no cloneing needed)::
 
-  pip install git+{{cookiecutter.gitlab_repo_path}}
+  pip install git+{{cookiecutter.gitlab_repo_url}}
 
 Or clone the repository and run::
 
diff --git a/{{cookiecutter.project_slug}}/doc/index.rst b/{{cookiecutter.project_slug}}/doc/index.rst
index 316db92..1c3d0ce 100644
--- a/{{cookiecutter.project_slug}}/doc/index.rst
+++ b/{{cookiecutter.project_slug}}/doc/index.rst
@@ -11,8 +11,8 @@
 
    autoapi/index
 
-   Code Coverage <http://{{cookiecutter.gitlab_username}}.pages.km3net.de/{{cookiecutter.project_slug}}/coverage>
-   Source (Git) <{{cookiecutter.gitlab_repo_path}}>
+   Code Coverage <http://{{cookiecutter.gitlab_username_or_group}}.pages.km3net.de/{{cookiecutter.project_slug}}/coverage>
+   Source (Git) <{{cookiecutter.gitlab_repo_url}}>
 
 
 
diff --git a/{{cookiecutter.project_slug}}/setup.cfg b/{{cookiecutter.project_slug}}/setup.cfg
index 0055855..b50e65d 100644
--- a/{{cookiecutter.project_slug}}/setup.cfg
+++ b/{{cookiecutter.project_slug}}/setup.cfg
@@ -3,7 +3,7 @@ name = {{cookiecutter.project_slug}}
 description = {{cookiecutter.description}}
 long_description = file: README.rst
 long_description_content_type = text/x-rst
-url = {{cookiecutter.gitlab_repo_path}}
+url = {{cookiecutter.gitlab_repo_url}}
 author = {{cookiecutter.author}}
 author_email = {{cookiecutter.email}}
 maintainer = {{cookiecutter.author}}
-- 
GitLab