241 lines
4.7 KiB
Markdown
241 lines
4.7 KiB
Markdown
# Examples
|
|
|
|
## Basic Repository Setup
|
|
|
|
```bash
|
|
# Using config file defaults
|
|
gitreposetup --owner MyOrg --name MyApp
|
|
|
|
# Output:
|
|
# Initialized new git repository
|
|
# Set remote 'origin' to: https://git.theprivateserver.de/MyOrg/MyApp.git
|
|
# Added LICENSE: MIT
|
|
# Added/updated .gitignore
|
|
# Created initial commit
|
|
# Created and switched to branch: dev
|
|
# ⚠️ Warning: Could not push to remote. Network may be unavailable...
|
|
# ✅ Repository setup complete!
|
|
```
|
|
|
|
## Python Package Project
|
|
|
|
```bash
|
|
gitreposetup \
|
|
--owner MyOrg \
|
|
--name my-python-lib \
|
|
--license MIT \
|
|
--deploy-type pypi
|
|
|
|
# Creates:
|
|
# - LICENSE (MIT, year: 2025, author: from git config)
|
|
# - .gitignore (Python/Rust/Go patterns)
|
|
# - .gitea/workflows/test-python.yml
|
|
# - .gitea/workflows/python_package-release.yml
|
|
# - .gitea/changelog_config.json
|
|
```
|
|
|
|
## Rust CLI Tool
|
|
|
|
```bash
|
|
gitreposetup \
|
|
--owner MyOrg \
|
|
--name rust-cli \
|
|
--license GPLv3 \
|
|
--deploy-type cargo
|
|
|
|
# Creates:
|
|
# - LICENSE (GPLv3)
|
|
# - .gitignore
|
|
# - .gitea/workflows/test-rust.yml
|
|
# - .gitea/workflows/cargo-release.yml
|
|
```
|
|
|
|
## Go Microservice with Docker
|
|
|
|
```bash
|
|
gitreposetup \
|
|
--owner MyOrg \
|
|
--name go-api \
|
|
--license AGPLv3 \
|
|
--deploy-type docker \
|
|
--develop-branch-name develop
|
|
|
|
# Creates:
|
|
# - LICENSE (AGPLv3)
|
|
# - .gitignore
|
|
# - .gitea/workflows/test-go.yml
|
|
# - .gitea/workflows/test-go-docker-build.yml
|
|
# - .gitea/workflows/docker-release.yml
|
|
# - Branches: main, develop
|
|
# ⚠️ Warning: Docker workflows require a Dockerfile in the repository root.
|
|
```
|
|
|
|
## Force Overwrite Existing LICENSE
|
|
|
|
```bash
|
|
# If LICENSE already exists and you want to change it
|
|
gitreposetup \
|
|
--owner MyOrg \
|
|
--name existing-repo \
|
|
--license Unlicense \
|
|
--force
|
|
|
|
# Replaces existing LICENSE with Unlicense
|
|
```
|
|
|
|
## Custom Git URL Template
|
|
|
|
```bash
|
|
# For GitHub or custom Git servers
|
|
gitreposetup \
|
|
--owner octocat \
|
|
--name hello-world \
|
|
--default-git-url "https://github.com/{owner}/{repo}.git"
|
|
|
|
# Set remote 'origin' to: https://github.com/octocat/hello-world.git
|
|
```
|
|
|
|
## Config File Setup
|
|
|
|
Create `~/.config/GMS/.config.yaml`:
|
|
|
|
```yaml
|
|
owner: MyOrg
|
|
name: "" # Can be overridden per-repo
|
|
license: MIT
|
|
develop_branch: dev
|
|
default_gitignore: true
|
|
default_git_url: "https://git.theprivateserver.de/{owner}/{repo}.git"
|
|
```
|
|
|
|
Then run without flags:
|
|
```bash
|
|
# Uses config defaults for owner, license, etc.
|
|
gitreposetup --name my-new-project
|
|
```
|
|
|
|
## Workflow Integration
|
|
|
|
### In a Gitea Workflow
|
|
|
|
```yaml
|
|
name: Setup and Deploy
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
repo_name:
|
|
description: 'Repository name'
|
|
required: true
|
|
|
|
jobs:
|
|
setup:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Download gitreposetup
|
|
run: |
|
|
curl -L -o gitreposetup https://releases.example.com/gitreposetup
|
|
chmod +x gitreposetup
|
|
|
|
- name: Setup repository
|
|
run: |
|
|
./gitreposetup \
|
|
--owner ${{ github.repository_owner }} \
|
|
--name ${{ github.event.inputs.repo_name }} \
|
|
--deploy-type docker
|
|
```
|
|
|
|
### Local Script
|
|
|
|
```bash
|
|
#!/bin/bash
|
|
# setup-new-project.sh
|
|
|
|
PROJECT_NAME=$1
|
|
DEPLOY_TYPE=${2:-docker}
|
|
|
|
if [ -z "$PROJECT_NAME" ]; then
|
|
echo "Usage: $0 <project-name> [deploy-type]"
|
|
exit 1
|
|
fi
|
|
|
|
mkdir "$PROJECT_NAME"
|
|
cd "$PROJECT_NAME"
|
|
|
|
gitreposetup \
|
|
--owner MyOrg \
|
|
--name "$PROJECT_NAME" \
|
|
--license MIT \
|
|
--deploy-type "$DEPLOY_TYPE"
|
|
|
|
echo "✅ Project $PROJECT_NAME ready!"
|
|
echo "Next steps:"
|
|
echo " 1. Add code to the repository"
|
|
echo " 2. Create remote in Gitea: https://git.theprivateserver.de/MyOrg/$PROJECT_NAME"
|
|
echo " 3. Push: git push -u origin main && git push -u origin dev"
|
|
```
|
|
|
|
## Verifying Setup
|
|
|
|
```bash
|
|
# Check git configuration
|
|
git remote -v
|
|
# origin https://git.theprivateserver.de/MyOrg/MyRepo.git (fetch)
|
|
# origin https://git.theprivateserver.de/MyOrg/MyRepo.git (push)
|
|
|
|
git branch -a
|
|
# * dev
|
|
# main
|
|
|
|
git log --oneline
|
|
# abc1234 Initial commit
|
|
|
|
# Check files
|
|
ls -la
|
|
# .git/
|
|
# .gitea/
|
|
# .gitignore
|
|
# LICENSE
|
|
|
|
ls .gitea/workflows/
|
|
# docker-release.yml
|
|
# test-python-docker-build.yml
|
|
# test-python.yml
|
|
```
|
|
|
|
## Multi-Repo Batch Setup
|
|
|
|
```powershell
|
|
# PowerShell script to set up multiple repos
|
|
$repos = @(
|
|
@{name="api-gateway"; type="go"}
|
|
@{name="user-service"; type="docker"}
|
|
@{name="data-pipeline"; type="pypi"}
|
|
)
|
|
|
|
foreach ($repo in $repos) {
|
|
Write-Host "Setting up $($repo.name)..."
|
|
New-Item -ItemType Directory -Path $repo.name -Force
|
|
Set-Location $repo.name
|
|
|
|
gitreposetup `
|
|
--owner MyOrg `
|
|
--name $repo.name `
|
|
--deploy-type $repo.type
|
|
|
|
Set-Location ..
|
|
}
|
|
```
|
|
|
|
## Public Domain Project
|
|
|
|
```bash
|
|
gitreposetup \
|
|
--owner PublicOrg \
|
|
--name open-data \
|
|
--license Unlicense \
|
|
--deploy-type pypi
|
|
|
|
# Creates LICENSE with Unlicense (public domain dedication)
|
|
```
|