cookie icon indicating copy to clipboard operation
cookie copied to clipboard

Unnecessary .github folder and missing dependabot implementation when using gitlab as repository host

Open mbwinkler opened this issue 1 year ago • 3 comments

Currently, creating a project from the template with a repository target hosted on gitlab results in an unnecessary .github folder and no dependabot implementation in .gitlab-ci.yml.

This could be fixed with the following logic:

  1. Always create all necessary CI/CD files for both gitlab & github on generation
  2. Remove unnecessary files/folders using a post-generation hook

This hook would be stored in hooks/post_gen_project.py and would look something like this

import os
import shutil

# Determine the target platform
target_platform = '{{ cookiecutter.__ci }}'

# Define paths to CI directories
github_ci_path = os.path.join(os.getcwd(), '.github')
gitlab_ci_file = os.path.join(os.getcwd(), '.gitlab-ci.yml')
gitlab_dependabot_file = os.path.join(os.getcwd(), 'dependabot.yml')

if target_platform == 'github':
    # Remove the GitLab CI file if the target is GitHub
    if os.path.exists(gitlab_ci_file):
        os.remove(gitlab_ci_file)
        os.remove(gitlab_dependabot_file)
elif target_platform == 'gitlab':
    # Remove the GitHub Actions directory if the target is GitLab
    if os.path.exists(github_ci_path):
        shutil.rmtree(github_ci_path)

mbwinkler avatar Jul 16 '24 21:07 mbwinkler