# Forgejo API — Repository Settings (EditRepoOption)

Base URL: `https://git.cleverthis.com/api/v1`

Endpoint: `PATCH /repos/{owner}/{repo}`

All fields are optional. Only include the fields you want to change.

---

## Complete EditRepoOption Field Reference

### Merge Strategy Settings

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `allow_merge_commits` | boolean | `true` | Allow merge commits (standard merge) |
| `allow_rebase` | boolean | `true` | Allow rebase merging (linear rebase, no merge commit) |
| `allow_rebase_explicit` | boolean | `true` | Allow rebase with explicit merge commit (rebase then merge commit) |
| `allow_rebase_update` | boolean | `true` | Allow updating PR branch via rebase |
| `allow_squash_merge` | boolean | `true` | Allow squash-and-merge (all commits squashed into one) |
| `allow_fast_forward_only_merge` | boolean | `false` | Allow fast-forward only merge (no merge commit, must be up-to-date) |
| `allow_manual_merge` | boolean | `false` | Allow marking PRs as manually merged |
| `autodetect_manual_merge` | boolean | `false` | Auto-detect when PR is manually merged |
| `default_merge_style` | string | `"merge"` | Default merge style for new PRs |
| `default_update_style` | string | `""` | Default style for updating PR branches |
| `default_allow_maintainer_edit` | boolean | `false` | Allow maintainers to edit PRs by default |
| `default_delete_branch_after_merge` | boolean | `false` | Auto-delete head branch after merge |
| `ignore_whitespace_conflicts` | boolean | `false` | Ignore whitespace in conflict detection |

**`default_merge_style` values:**

| Value | Description |
|-------|-------------|
| `"merge"` | Standard merge commit |
| `"rebase"` | Rebase (no merge commit) |
| `"rebase-merge"` | Rebase with merge commit |
| `"squash"` | Squash all commits into one |
| `"fast-forward-only"` | Fast-forward only (requires branch to be up-to-date) |

**`default_update_style` values:**

| Value | Description |
|-------|-------------|
| `"rebase"` | Rebase PR branch onto base branch |
| `"merge"` | Merge base branch into PR branch |

```bash
# Enable only squash and rebase merging, disable standard merge
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "allow_merge_commits": false,
    "allow_rebase": true,
    "allow_rebase_explicit": false,
    "allow_squash_merge": true,
    "allow_fast_forward_only_merge": false,
    "default_merge_style": "squash"
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"

# Enable auto-delete branch after merge
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "default_delete_branch_after_merge": true
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"

# Allow manual merge with auto-detection
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "allow_manual_merge": true,
    "autodetect_manual_merge": true
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"

# Set default update style to rebase
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "default_update_style": "rebase"
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"

# Allow maintainers to edit PRs by default
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "default_allow_maintainer_edit": true
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"

# Enable fast-forward only merge as default
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "allow_merge_commits": false,
    "allow_rebase": false,
    "allow_rebase_explicit": false,
    "allow_squash_merge": false,
    "allow_fast_forward_only_merge": true,
    "default_merge_style": "fast-forward-only"
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"

# Ignore whitespace conflicts
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "ignore_whitespace_conflicts": true
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"
```

---

### Feature Toggle Settings

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `has_issues` | boolean | `true` | Enable/disable issue tracker |
| `has_wiki` | boolean | `true` | Enable/disable wiki |
| `has_pull_requests` | boolean | `true` | Enable/disable pull requests |
| `has_projects` | boolean | `true` | Enable/disable project boards |
| `has_actions` | boolean | `true` | Enable/disable CI/CD actions |
| `has_packages` | boolean | `true` | Enable/disable package registry |
| `has_releases` | boolean | `true` | Enable/disable releases |

```bash
# Disable wiki and projects, keep issues and PRs
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "has_issues": true,
    "has_wiki": false,
    "has_pull_requests": true,
    "has_projects": false,
    "has_actions": true,
    "has_packages": false,
    "has_releases": true
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"

# Mirror-style repo: disable issues, PRs, wiki
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "has_issues": false,
    "has_wiki": false,
    "has_pull_requests": false,
    "has_projects": false
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"

# Enable actions for CI/CD
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "has_actions": true
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"
```

---

### Repository State Settings

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `archived` | boolean | `false` | Archive the repository (read-only mode) |
| `private` | boolean | `false` | Make repository private/public |
| `template` | boolean | `false` | Mark as template repository |

```bash
# Archive a repository
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "archived": true
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"

# Unarchive a repository
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "archived": false
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"

# Make repository private
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "private": true
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"

# Make repository public
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "private": false
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"

# Convert to template repository
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "template": true
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"
```

---

### Basic Metadata Settings

| Field | Type | Description |
|-------|------|-------------|
| `name` | string | Rename the repository |
| `description` | string | Repository description |
| `website` | string | Associated website URL |
| `default_branch` | string | Default branch name |

```bash
# Rename a repository
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "{repo}"
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"

# Update description and website
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "description": "{description}",
    "website": "https://myproject.example.com"
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"

# Change default branch
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "default_branch": "{branch}"
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"

# Change default branch back to main
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "default_branch": "{branch}"
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"
```

---

### External Tracker Settings

| Field | Type | Description |
|-------|------|-------------|
| `external_tracker` | object | External issue tracker configuration |
| `external_tracker.external_tracker_url` | string | URL of external tracker |
| `external_tracker.external_tracker_format` | string | URL format for issues (use `{index}` placeholder) |
| `external_tracker.external_tracker_style` | string | Style: `"numeric"`, `"alphanumeric"`, `"regexp"` |
| `external_tracker.external_tracker_regexp_pattern` | string | Custom regex pattern (if style is `"regexp"`) |

```bash
# Configure external issue tracker (e.g., Jira)
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "has_issues": true,
    "external_tracker": {
      "external_tracker_url": "https://jira.example.com",
      "external_tracker_format": "https://jira.example.com/browse/{index}",
      "external_tracker_style": "alphanumeric"
    }
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"

# Use numeric external tracker (e.g., Bugzilla)
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "has_issues": true,
    "external_tracker": {
      "external_tracker_url": "https://bugs.example.com",
      "external_tracker_format": "https://bugs.example.com/show_bug.cgi?id={index}",
      "external_tracker_style": "numeric"
    }
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"

# Use regexp-based external tracker
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "has_issues": true,
    "external_tracker": {
      "external_tracker_url": "https://tracker.example.com",
      "external_tracker_format": "https://tracker.example.com/issue/{index}",
      "external_tracker_style": "regexp",
      "external_tracker_regexp_pattern": "PROJ-[0-9]+"
    }
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"

# Remove external tracker (revert to internal)
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "has_issues": true,
    "external_tracker": null
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"
```

---

### External Wiki Settings

| Field | Type | Description |
|-------|------|-------------|
| `external_wiki` | object | External wiki configuration |
| `external_wiki.external_wiki_url` | string | URL of external wiki |

```bash
# Configure external wiki
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "has_wiki": true,
    "external_wiki": {
      "external_wiki_url": "https://wiki.example.com/myproject"
    }
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"

# Remove external wiki (revert to internal)
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "has_wiki": true,
    "external_wiki": null
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"
```

---

### Internal Tracker Settings

| Field | Type | Description |
|-------|------|-------------|
| `internal_tracker` | object | Internal issue tracker configuration |
| `internal_tracker.enable_time_tracker` | boolean | Enable time tracking on issues |
| `internal_tracker.allow_only_contributors_to_track_time` | boolean | Only contributors can track time |
| `internal_tracker.enable_issue_dependencies` | boolean | Enable issue dependency tracking |

```bash
# Configure internal tracker with time tracking
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "internal_tracker": {
      "enable_time_tracker": true,
      "allow_only_contributors_to_track_time": true,
      "enable_issue_dependencies": true
    }
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"

# Disable time tracking
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "internal_tracker": {
      "enable_time_tracker": false,
      "allow_only_contributors_to_track_time": false,
      "enable_issue_dependencies": true
    }
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"
```

---

### Wiki Settings

| Field | Type | Description |
|-------|------|-------------|
| `globally_editable_wiki` | boolean | Allow anyone (not just collaborators) to edit wiki |
| `wiki_branch` | string | Branch used for wiki content (default: `"master"`) |

```bash
# Make wiki globally editable
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "has_wiki": true,
    "globally_editable_wiki": true
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"

# Set custom wiki branch
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "has_wiki": true,
    "wiki_branch": "wiki"
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"

# Restrict wiki editing to collaborators only
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "globally_editable_wiki": false
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"
```

---

### Mirror Settings

| Field | Type | Description |
|-------|------|-------------|
| `mirror_interval` | string | Mirror sync interval (e.g., `"8h"`, `"1d"`, `"168h"`) |
| `enable_prune` | boolean | Prune stale remote-tracking references during mirror sync |

```bash
# Change mirror sync interval to every 4 hours
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "mirror_interval": "4h"
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"

# Set daily mirror sync with pruning
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "mirror_interval": "24h",
    "enable_prune": true
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"

# Set weekly mirror sync
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "mirror_interval": "168h"
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"
```

---

## Comprehensive Examples

### Full Configuration for a Production Repository

```bash
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "description": "{description}",
    "website": "https://app.example.com",
    "private": true,
    "has_issues": true,
    "has_wiki": true,
    "has_pull_requests": true,
    "has_projects": true,
    "has_actions": true,
    "has_packages": true,
    "has_releases": true,
    "allow_merge_commits": false,
    "allow_rebase": false,
    "allow_rebase_explicit": false,
    "allow_squash_merge": true,
    "allow_fast_forward_only_merge": false,
    "default_merge_style": "squash",
    "default_delete_branch_after_merge": true,
    "default_allow_maintainer_edit": true,
    "default_update_style": "rebase",
    "ignore_whitespace_conflicts": false,
    "internal_tracker": {
      "enable_time_tracker": true,
      "allow_only_contributors_to_track_time": true,
      "enable_issue_dependencies": true
    }
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"
```

### Minimal Documentation-Only Repository

```bash
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "has_issues": false,
    "has_wiki": true,
    "has_pull_requests": true,
    "has_projects": false,
    "has_actions": false,
    "has_packages": false,
    "has_releases": false,
    "globally_editable_wiki": true
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"
```

### Convert Repo to Read-Only Archive

```bash
curl -s -X PATCH \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{
    "archived": true,
    "has_issues": false,
    "has_wiki": false,
    "has_pull_requests": false,
    "has_projects": false,
    "has_actions": false
  }' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}"
```

---

## Response

**Success:** `200 OK` — Returns the full `{Repository}` object with updated fields.

**Errors:**
- `403 Forbidden` — Insufficient permissions (admin required for most settings)
- `404 Not Found` — Repository does not exist
- `422 Unprocessable Entity` — Invalid field values
