Commit d3d6c0a3 authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

feat: add cache dir argument

parent a30228ca
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -16,8 +16,8 @@ gitlab-cp --help
## Usage

```bash
usage: gitlab-cp [-h] --src-api SRC_API [--src-token SRC_TOKEN] --src-sync-path SRC_SYNC_PATH --dest-api DEST_API --dest-token DEST_TOKEN [--dest-sync-path DEST_SYNC_PATH] [--max-visibility {public,internal,private}]
                 [--exclude EXCLUDE] [--insecure] [--update-release] [--update-avatar] [--no-group-description] [--no-project-description] [--dry-run] [--halt-on-error]
usage: gitlab-cp [-h] [--src-api SRC_API] [--src-token SRC_TOKEN] [--src-sync-path SRC_SYNC_PATH] [--dest-api DEST_API] [--dest-token DEST_TOKEN] [--dest-sync-path DEST_SYNC_PATH] [--max-visibility {public,internal,private}] [--exclude EXCLUDE] [--insecure]
                 [--update-release] [--update-avatar] [--no-group-description] [--no-project-description] [--dry-run] [--halt-on-error] [--cache-dir CACHE_DIR]

This tool recursively copies/synchronizes a GitLab group from one GitLab server to another.

@@ -41,10 +41,12 @@ options:
  --update-avatar       force update the avatar images even when they exist and look the same
  --no-group-description
                        don't synchronize group description
  --no_project-description
  --no-project-description
                        don't synchronize project description
  --dry-run             dry run (don't execute any write action)
  --halt-on-error       halt synchronizing whenever an error occurs
  --cache-dir CACHE_DIR
                        cache directory (used to download resources such as images and Git repositories)
```

| CLI option                 | Env. Variable                   | Description                                                                                                           |
@@ -64,6 +66,7 @@ options:
| `--no-project-description` | `$PROJECT_DESCRIPTION_DISABLED` | don't synchronize project description                                                                                 |
| `--dry-run`                | _none_                          | dry run (don't execute any write action)                                                                              |
| `--halt-on-error`          | _none_                          | halt synchronizing when an error occurs                                                                               |
| `--cache-dir`              | `$CACHE_DIR`                    | cache directory (used to download resources such as images and Git repositories) (defaults to `.work`)                |

## Developers

+9 −1
Original line number Diff line number Diff line
@@ -785,6 +785,11 @@ def run():
        action="store_true",
        help="halt synchronizing whenever an error occurs",
    )
    parser.add_argument(
        "--cache-dir",
        default=os.getenv("CACHE_DIR", ".work"),
        help="cache directory (used to download resources such as images and Git repositories)",
    )

    # parse command and args
    args = parser.parse_args()
@@ -839,6 +844,9 @@ def run():
    print(
        f"- halt on err. (--halt-on-error) : {AnsiColors.CYAN}{args.halt_on_error}{AnsiColors.RESET}"
    )
    print(
        f"- cache dir   (--cache-dir)      : {AnsiColors.CYAN}{args.cache_dir}{AnsiColors.RESET}"
    )
    print(
        f"- skip group desc.   (--no-group-description)   : {AnsiColors.CYAN}{args.no_group_description}{AnsiColors.RESET}"
    )
@@ -848,7 +856,7 @@ def run():
    print()

    # TODO: configurable
    work_dir = Path(".work")
    work_dir = Path(args.cache_dir)
    work_dir.mkdir(exist_ok=True)

    client = Synchronizer(