Skip to content

Commit

Permalink
refactor: rename repo_host to repo_platform (#249)
Browse files Browse the repository at this point in the history
Close #247

Signed-off-by: msclock <[email protected]>
  • Loading branch information
msclock authored May 13, 2024
1 parent 7365a49 commit f677e63
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 30 deletions.
27 changes: 16 additions & 11 deletions copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,31 +84,36 @@ author_email:
help: 'Specify the email address of the author:'
type: str

repo_host_type:
default: github.com
repo_platform:
default: github
choices:
GitHub: github.com
GitLab: gitlab.com
GitHub: github
GitLab: gitlab
GitLab (self-managed): gitlab-self-managed
help: 'Choose the host for the repository:'
help: 'Choose the platform for the repository:'
type: str

repo_host:
default: '{{ repo_host_type }}'
default: |-
[% if repo_platform == 'github' -%]
github.com
[%- elif repo_platform == 'gitlab' -%]
gitlab.com
[%- endif %]
help: 'Specify the host of the self-managed GitLab:'
type: str
when: '{{ repo_host_type == "gitlab-self-managed" }}'
when: '{{ repo_platform == "gitlab-self-managed" }}'

page_host:
default: |-
[% if repo_host_type == 'github.com' -%]
[% if repo_platform == 'github' -%]
github.io
[%- elif repo_host_type == 'gitlab.com' -%]
[%- elif repo_platform == 'gitlab' -%]
gitlab.io
[%- endif %]
help: 'Specify the host of the self-managed GitLab Pages:'
type: str
when: '{{ repo_host_type == "gitlab-self-managed" }}'
when: '{{ repo_platform == "gitlab-self-managed" }}'

repo_namespace:
default: '{{ organization_name|lower|replace(" ", "-") }}'
Expand Down Expand Up @@ -188,4 +193,4 @@ use_codeql:
default: true
help: 'Whether to add codeql integration:'
type: bool
when: '{{ repo_host_type == "github.com" }}'
when: '{{ repo_platform == "github.com" }}'
24 changes: 12 additions & 12 deletions includes/variable.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
[%- endmacro %]

[% macro page_url() -%]
[% if repo_host_type == 'github.com' -%]
[% if repo_platform == 'github' -%]
{{ repo_namespace }}.github.io/{{ repo_name }}
[%- elif repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' -%]
[%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' -%]
[%- set repo_namespace_root = repo_namespace.split("/")[0] -%]
{{ repo_namespace_root }}.{{ page_host }}{{ repo_namespace | replace(repo_namespace_root, "", 1) }}/{{ repo_name }}
[%- endif %]
[%- endmacro %]

[% macro license_url() -%]
[% if repo_host_type == 'github.com' -%]
[% if repo_platform == 'github' -%]
https://{{ repo_url() }}/blob/master/LICENSE
[%- elif repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' -%]
[%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' -%]
https://{{ repo_url() }}/-/blob/master/LICENSE
[%- endif -%]
[%- endmacro %]
Expand All @@ -26,37 +26,37 @@
[%- endmacro %]

[% macro license_badge() -%]
[% if repo_host_type == 'github.com' -%]
[% if repo_platform == 'github' -%]
[![License](https://img.shields.io/github/license/{{ repo_namespace }}/{{ repo_name }})]({{ license_url() }})
[%- elif repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' -%]
[%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' -%]
[![License](https://img.shields.io/gitlab/license/{{ repo_namespace }}/{{ repo_name }}?gitlab_url=https%3A%2F%2F{{ repo_host }})]({{ license_url() }})
[%- endif -%]
[%- endmacro %]

[% macro pipeline_badge() -%]
[% if repo_host_type == 'github.com' -%]
[% if repo_platform == 'github' -%]
[![CI](https://{{ repo_url() }}/actions/workflows/ci.yml/badge.svg)](https://{{ repo_url() }}/actions/workflows/ci.yml)
[![CD](https://{{ repo_url() }}/actions/workflows/cd.yml/badge.svg)](https://{{ repo_url() }}/actions/workflows/cd.yml)
[![Renovate](https://{{ repo_url() }}/actions/workflows/renovate.yml/badge.svg)](https://{{ repo_url() }}/actions/workflows/renovate.yml)
[%- elif repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' -%]
[%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' -%]
[![CI](https://{{ repo_url() }}/badges/master/pipeline.svg)](https://{{ repo_url() }}/-/commits/master)
[%- endif %]
[%- endmacro %]

[% macro codecov_badge() -%]
[% if use_codecov == true -%]
[%- if repo_host_type == 'github.com' -%]
[%- if repo_platform == 'github' -%]
[![codecov](https://codecov.io/gh/{{ repo_namespace }}/{{ repo_name }}/branch/master/graph/badge.svg?token=123456789)](https://codecov.io/gh/{{ repo_namespace }}/{{ repo_name }})
[%- elif repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' -%]
[%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' -%]
[![codecov](https://codecov.io/gh/{{ repo_namespace }}/{{ repo_name }}/branch/master/graph/badge.svg?token=123456789)](https://codecov.io/gh/{{ repo_namespace }}/{{ repo_name }})
[%- endif -%]
[%- endif -%]
[%- endmacro %]

[% macro release_badge() -%]
[% if repo_host_type == 'github.com' -%]
[% if repo_platform == 'github' -%]
[![Release](https://img.shields.io/github/v/release/{{ repo_namespace }}/{{ repo_name }})](https://github.com/{{ repo_namespace }}/{{ repo_name }}/releases)
[%- elif repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' -%]
[%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' -%]
[![Release](https://{{ repo_url() }}/-/badges/release.svg)](https://{{ repo_url() }}/-/releases)
[%- endif -%]
[%- endmacro %]
6 changes: 3 additions & 3 deletions template/.renovaterc.json.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended",
[%- if repo_name == 'ss-cpp' or repo_host_type == 'github.com' %]
[%- if repo_name == 'ss-cpp' or repo_platform == 'github' %]
"helpers:pinGitHubActionDigests",
[%- endif %]
":enablePreCommit",
Expand Down Expand Up @@ -89,10 +89,10 @@
"automerge": true,
"schedule": ["before 8:00pm on the first day of the month"],
"matchDepNames": [
[%- if repo_host_type == 'github.com' %]
[%- if repo_platform == 'github' %]
"ghcr.io/renovatebot/renovate",
[%- endif %]
[%- if repo_host_type == 'gitlab.com' or reop_host_type == 'gitlab-self-managed' or repo_name == 'ss-cpp' %]
[%- if repo_platform == 'gitlab' or reop_host_type == 'gitlab-self-managed' or repo_name == 'ss-cpp' %]
"renovate/renovate",
[%- endif %]
"renovatebot/pre-commit-hooks"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,16 @@ html_css_files = [
html_theme_options = {
"footer_icons": [
{
[%- if repo_host_type == 'github.com' %]
[%- if repo_platform == 'github' %]
"name": "GitHub",
[%- elif repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %]
[%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %]
"name": "GitLab",
[%- endif %]
"url": "https://{{ repo_url() }}",
"html": "",
[%- if repo_host_type == 'github.com' %]
[%- if repo_platform == 'github' %]
"class": "fa-brands fa-solid fa-github fa-lg",
[%- elif repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %]
[%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %]
"class": "fa-brands fa-solid fa-gitlab fa-lg",
[%- endif %]
},
Expand Down

0 comments on commit f677e63

Please sign in to comment.