Gitlab
MicrosoftOfficialPublished by Microsoft
- Skill
- Tool integration
- Software development
- MIT
- Low risk
- Has scripts
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
The GitLab skill provides a repository-local Python interface for interacting with GitLab.com or self-managed GitLab instances. It enables users to perform common development tasks such as listing and updating merge requests, triggering pipelines, and inspecting job logs directly from the command line. The tool supports both OAuth and legacy personal access token authentication modes and includes optional audit logging for tracking API operations.
What it does
- Authenticates via OAuth or legacy personal access tokens
- Lists, creates, and updates merge requests
- Retrieves merge request notes and comments
- Triggers pipelines for specific branches or tags
- Lists pipeline jobs and retrieves raw job logs
- Provides structured audit logging for API requests
When to use it
- When you need to automate GitLab interactions within a local development workflow
- When you prefer a command-line interface for managing merge requests and pipelines
- When you need to extract specific data fields from GitLab resources for reporting
- When you require an auditable trail of API operations for internal tracking
Advantages
- Supports concise output filtering using the --fields parameter
- Integrates with existing git repositories via automatic project detection
- Offers secure OAuth authentication with PKCE support
- Provides a structured JSON Lines audit trail for operations
Usage examples
- “List all open merge requests for the current project.”
- The CLI outputs a list of open merge requests, displaying the IID, title, and author name for each.
- “Get the job logs for pipeline 12345.”
- The CLI retrieves and prints the raw log output for the specified pipeline job.
- “Create a new merge request from a JSON payload.”
- The CLI submits the provided JSON data to create a new merge request on the configured GitLab project.
- “Add a comment to merge request 42.”
- The CLI posts the provided text as a comment on the specified merge request.
Install
8 of its files are not mirrored here, so install it from its source:
https://github.com/microsoft/hve-core/tree/f425e943bf228052a23e6bc4810b5faef030314f/.github/skills/project-planning/gitlab
Documentation by Microsoft
GitLab Skill
Overview
Use this skill to inspect and update GitLab merge requests, notes, pipelines, and job logs against GitLab.com or self-managed GitLab instances.
This skill is the repository-local Python workflow for GitLab tasks. It is not the official GitLab MCP server integration surface.
This first hve-core implementation is Python-only. Run the CLI through
python scripts/gitlab.py and prefer --fields for read operations to keep
output concise.
Prerequisites
The skill requires Python 3.11 or later.
Set these environment variables before running any command:
| Variable | Required | Example | Purpose |
|---|---|---|---|
GITLAB_URL | Yes | https://gitlab.com | GitLab instance URL |
GITLAB_AUTH_MODE | Optional | oauth | oauth or explicit legacy-token compatibility mode |
GITLAB_OAUTH_CLIENT_ID | OAuth | Application ID | Non-confidential OAuth application ID; no client secret |
GITLAB_TOKEN | Legacy mode | glpat-... | PAT accepted only with GITLAB_AUTH_MODE=legacy-token |
GITLAB_PROFILE | No | default | Named OAuth profile |
GITLAB_TOKEN_STORE | No | path | OAuth store override; parent must be owner-only on POSIX |
GITLAB_ALLOW_INSECURE | No | 1 | Permit explicit loopback HTTP development endpoints only |
XDG_DATA_HOME | No | path | POSIX data root used for the default OAuth store |
LOCALAPPDATA | No | path | Reserved Windows data root; OAuth persistence currently fails closed on Windows |
GITLAB_PROJECT | No | group/project | Project path or numeric project ID |
If GITLAB_PROJECT is not set, the script attempts to detect the project from
git remote get-url origin. Set the variable explicitly when you are not in a
git repository or when you want to target a different project.
Operational Variables
| Variable | Required | Purpose |
|---|---|---|
GITLAB_AUDIT_LOG | No | Path to a JSON Lines audit log. When set, every request is audited (see Audit Logging). |
GITLAB_AUDIT_ACTOR | No | Overrides the recorded actor identity (for example, a CI service principal). |
GITLAB_DEBUG | No | Set to 1 to print a redacted traceback on failure. Never disables redaction. |
Audit Logging
When GITLAB_AUDIT_LOG is set, the script writes a structured JSON Lines audit trail for every REST API and OAuth form request. Auditing is fail-closed and write-ahead:
An
attemptrecord is written before the request is sent. If the audit log cannot be written, the operation is aborted and nothing is sent to GitLab.An
outcomerecord (successorerror, with HTTP status on failure) is written after the request completes.
REST records include a UTC timestamp, actor, auth mode, normalized origin, operation, HTTP method, and event. OAuth records use bounded operation and failure kinds without actor, origin, client, profile, code, body, or free-form error fields. Resource paths, queries, profile names, and profile contents are excluded. The optional audit sink is operationally sensitive because origins can identify tenants or internal hosts. Place it at an access-controlled path and retain it only as long as operations require. Tokens and authorization headers are never written. Audit failures after the request emit a warning without altering the result.
Credential Rotation
OAuth is the default. Register a non-confidential user-, group-, or self-managed
instance-owned application with redirect URI
http://127.0.0.1:8766/callback and the api scope. Set only
GITLAB_URL and GITLAB_OAUTH_CLIENT_ID, then run auth login or the
human-assisted auth device-login. Browser login requires a rotating refresh
token; access tokens refresh before expiry and replacements are stored
atomically. Device login can return an access-token-only profile and then
requires another device login after expiry. A provider/local crash window can
still require re-login.
The default store is $XDG_DATA_HOME/hve-core/gitlab/gitlab-token.json on
POSIX, falling back to ~/.local/share/hve-core/gitlab/gitlab-token.json.
POSIX store and lock files use mode 0600 inside a dedicated owner-only
directory. OAuth profile persistence fails closed on Windows because Python
3.11 mode bits cannot enforce an owner-only DACL. Use explicit
legacy-token mode on Windows until a protected OAuth backend is available.
PAT authentication remains available through GITLAB_AUTH_MODE=legacy-token.
Device authorization requires user approval on a browser-capable device and is
not unattended workload identity.
Quick Start
Export your environment variables, then run a read command with --fields.
export GITLAB_URL="https://gitlab.com"
export GITLAB_OAUTH_CLIENT_ID="your-application-id"
export GITLAB_PROJECT="group/project"
python scripts/gitlab.py auth login
python scripts/gitlab.py mr-list opened --fields iid,title,author.nameRead pipeline jobs for a known pipeline:
python scripts/gitlab.py pipeline-jobs 12345 --fields id,name,status,stageParameters Reference
Common Option
| Parameter | Applies To | Example | Description |
|---|---|---|---|
--fields | mr-list, mr-get, mr-notes, pipeline-get, pipeline-jobs | --fields iid,title,state | Extract specific fields with dot notation and print concise tabular or key-value output |
Commands
| Command | Arguments | Description |
|---|---|---|
auth login | None | Authenticate with Authorization Code and PKCE |
auth device-login | None | Authenticate through human-assisted device authorization |
auth status | None | Print secret-free local profile status |
auth logout | None | Delete one local profile without revoking server authorization |
mr-list | [state] [max] | List merge requests, defaulting to all states and 20 results |
mr-get | <mr-iid> | Get one merge request by project-scoped IID |
mr-create | <json> or stdin | Create a merge request from a JSON payload |
mr-update | <mr-iid> <json> or stdin | Update merge request fields from a JSON payload |
mr-comment | <mr-iid> <body> or stdin | Add a comment to a merge request |
mr-notes | <mr-iid> [max] | List merge request notes, excluding system notes when using --fields |
pipeline-get | <pipeline-id> | Get one pipeline by numeric ID |
pipeline-run | <branch-or-tag> | Trigger a pipeline for a branch or tag |
pipeline-jobs | <pipeline-id> | List jobs for a pipeline |
job-log | <job-id> | Print raw log output for a job |
Script Reference
List recent open merge requests:
python scripts/gitlab.py mr-list opened --fields iid,title,author.name,user_notes_countGet one merge request:
python scripts/gitlab.py mr-get 42 --fields iid,title,state,source_branch,target_branchCreate a merge request from inline JSON:
python scripts/gitlab.py mr-create '{
"source_branch": "feature/add-auth",
"target_branch": "main",
"title": "feat(auth): add OAuth login"
}'Add a merge request comment from standard input:
echo "CI passed. Ready for review." | python scripts/gitlab.py mr-comment 42Inspect a failed pipeline:
python scripts/gitlab.py pipeline-get 12345 --fields id,status,web_url
python scripts/gitlab.py pipeline-jobs 12345 --fields id,name,status,stage
python scripts/gitlab.py job-log 67890Troubleshooting
| Symptom | Cause | Resolution |
|---|---|---|
GITLAB_URL is not set | Required environment variable missing | Export GITLAB_URL before running the script |
GITLAB_TOKEN is not set for legacy-token mode | Explicit legacy mode has no PAT | Export a PAT only with GITLAB_AUTH_MODE=legacy-token |
GITLAB_TOKEN must not be set in oauth mode | Legacy PAT leaked into the OAuth configuration | Remove GITLAB_TOKEN or explicitly select legacy-token mode |
| OAuth persistence is unavailable on Windows | No protected Windows profile-store backend | Use explicit legacy-token mode or run OAuth from POSIX |
GITLAB_OAUTH_CLIENT_ID is not set | OAuth application is not configured | Set the public client ID, then run auth login |
| Callback listener cannot bind | Port 8766 is unavailable or not forwarded | Free the port or use auth device-login |
timed out waiting for the GitLab OAuth token store lock | Another process holds the profile-store lock | Wait for the other command to finish, then retry |
GitLab device response has invalid verification_uri | The verification URI is unsafe to display or does not match GITLAB_URL | Confirm GITLAB_URL matches the instance that serves device verification |
cannot parse git remote URL | Project autodetection failed | Set GITLAB_PROJECT explicitly |
HTTP 401 or HTTP 403 | Credential is invalid or lacks access | Re-login for OAuth; rotate the PAT in explicit legacy mode |
HTTP 404 | Wrong project, MR IID, pipeline ID, or job ID | Verify GITLAB_PROJECT and confirm the numeric identifiers |
expected numeric ID | Non-numeric value passed to an ID argument | Use project MR IID values and numeric pipeline or job IDs |
python3 is required or syntax errors on launch | Unsupported interpreter | Run the script with Python 3.11 or later |
GitLab uses MR IIDs such as !42 inside a project. This skill expects the
numeric IID, not the global merge request ID.
Files
- ATTRIBUTION.mdAdded by AutoGineer825 B
- LICENSELicence file added by AutoGineer1.1 KiB
- SECURITY.md33.4 KiB
- SKILL.md12.9 KiB
- pyproject.toml801 B
- scripts/_gitlab_credentials.pyScript15.1 KiB
- scripts/_gitlab_oauth.pyScript24.0 KiB
- scripts/gitlab.pyScript53.5 KiB
- tests/conftest.pyScript5.8 KiB
- tests/corpus/0814fd5a169c01a1448b1817d8ac617d6f277db8(opens on GitHub)Not mirrored: opens on GitHub6 B
- tests/corpus/0_empty(opens on GitHub)Not mirrored: opens on GitHub1 B
- tests/corpus/0_large(opens on GitHub)Not mirrored: opens on GitHub2.0 KiB
- tests/corpus/0_no_suffix(opens on GitHub)Not mirrored: opens on GitHub5 B
- tests/corpus/0_remote_path(opens on GitHub)Not mirrored: opens on GitHub18 B
- tests/corpus/0_unicode(opens on GitHub)Not mirrored: opens on GitHub11 B
- tests/corpus/0_with_suffix(opens on GitHub)Not mirrored: opens on GitHub9 B
- tests/corpus/1_empty1 B
- tests/corpus/1_float5 B
- tests/corpus/1_large15 B
- tests/corpus/1_negative3 B
- tests/corpus/1_numeric_id6 B
- tests/corpus/1_valid_id6 B
- tests/corpus/2_deeply_nested604 B
- tests/corpus/2_empty1 B
- tests/corpus/2_field_path12 B
- tests/corpus/2_nested_json26 B
- tests/corpus/2_unicode29 B
- tests/corpus/3_empty1 B
- tests/corpus/3_json_payload15 B
- tests/corpus/3_large2.0 KiB
- tests/corpus/3_malformed10 B
- tests/corpus/3_trailing10 B
- tests/corpus/3_valid_json35 B
- tests/corpus/4_empty1 B
- tests/corpus/4_float5 B
- tests/corpus/4_large15 B
- tests/corpus/4_negative3 B
- tests/corpus/4_positive_int3 B
- tests/corpus/4_unicode10 B
- tests/corpus/4_zero2 B
- tests/corpus/5_empty1 B
- tests/corpus/5_field_flag18 B
- tests/corpus/5_large899 B
- tests/corpus/5_mr_list8 B
- tests/corpus/5_multi_field25 B
- tests/corpus/5_single_field12 B
- tests/corpus/5_unicode25 B
- tests/corpus/README.md1.5 KiB
- tests/corpus/ee123d57ee4d24cece23066fb721013d717824f2(opens on GitHub)Not mirrored: opens on GitHub37 B
- tests/fuzz_harness.pyScript7.6 KiB
- tests/test_constants.pyScript1.2 KiB
- tests/test_gitlab_audit.pyScript7.8 KiB
- tests/test_gitlab_commands.pyScript10.0 KiB
- tests/test_gitlab_coverage.pyScript4.2 KiB
- tests/test_gitlab_credentials.pyScript13.2 KiB
- tests/test_gitlab_helpers.pyScript25.7 KiB
- tests/test_gitlab_main.pyScript13.2 KiB
- tests/test_gitlab_oauth.pyScript18.1 KiB
- tests/test_gitlab_transport.pyScript31.1 KiB
- uv.lock57.5 KiB
scripts/_gitlab_credentials.py
#!/usr/bin/env python3
# Copyright (c) 2026 Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: MIT
"""Credential profile persistence for the GitLab skill CLI."""
from __future__ import annotations
import errno
import json
import os
import pathlib
import re
import stat
import tempfile
import threading
import time
import urllib.parse
from contextlib import contextmanager
from typing import Any, Iterator, TypedDict, cast
SCHEMA_VERSION = 1
DEFAULT_PROFILE = "default"
LOCK_ACQUISITION_TIMEOUT_SECONDS = 60.0
LOCK_RETRY_INTERVAL_SECONDS = 0.1
_PROFILE_RE = re.compile(r"^[A-Za-z0-9_][A-Za-z0-9_.-]{0,31}$")
_REQUIRED_PROFILE_KEYS = {
"issuer",
"client_id",
"access_token",
"refresh_token",
"token_type",
"obtained_at",
"expires_at",
"scopes",
"usable",
}
_PROCESS_LOCK = threading.RLock()
_LOCK_CONTENTION_ERRNOS = frozenset(
value
for value in (
getattr(errno, "EACCES", None),
getattr(errno, "EAGAIN", None),
getattr(errno, "EWOULDBLOCK", None),
)
if value is not None
)
class CredentialError(ValueError):
"""Base error for GitLab OAuth credential-store failures."""
class CredentialSecurityError(CredentialError):
"""Raised when credential storage fails an ownership or permission check."""
class CredentialValidationError(CredentialError):
"""Raised when a credential profile or store payload is malformed."""
class Profile(TypedDict):
"""Persisted GitLab OAuth profile."""
issuer: str
client_id: str
access_token: str
refresh_token: str
token_type: str
obtained_at: int
expires_at: int
scopes: list[str]
usable: bool
try: # pragma: no cover - platform specific
import fcntl as _fcntl
except ImportError: # pragma: no cover - Windows
_fcntl = None # type: ignore[assignment]
try: # pragma: no cover - platform specific
import msvcrt as _msvcrt
except ImportError: # pragma: no cover - POSIX
_msvcrt = None # type: ignore[assignment]
def validate_profile_name(name: str) -> str:
"""Return a safe profile name or raise a validation error."""
if not isinstance(name, str) or not _PROFILE_RE.fullmatch(name):
raise CredentialValidationError("GitLab profile name is invalid")
return name
def resolve_profile_name(explicit: str | None, env: dict[str, str]) -> str:
"""Resolve the active profile from CLI input, environment, or default."""
selected = explicit or env.get("GITLAB_PROFILE") or DEFAULT_PROFILE
return validate_profile_name(selected)
def resolve_store_path(env: dict[str, str]) -> pathlib.Path:
"""Resolve the GitLab OAuth profile-store path."""
explicit = env.get("GITLAB_TOKEN_STORE", "").strip()
if explicit:
return pathlib.Path(explicit).expanduser()
if os.name == "nt": # pragma: no cover - Windows
local_app_data = env.get("LOCALAPPDATA", "").strip()
root = (
pathlib.Path(local_app_data).expanduser()
if local_app_data
else pathlib.Path.home() / "AppData/Local"
)
return root / "hve-core" / "gitlab" / "gitlab-token.json"
xdg = env.get("XDG_DATA_HOME", "").strip()
root = (
pathlib.Path(xdg).expanduser() if xdg else pathlib.Path.home() / ".local/share"
)
return root / "hve-core" / "gitlab" / "gitlab-token.json"
def _validate_issuer(value: str) -> None:
"""Require a canonical origin-only GitLab issuer."""
try:
parsed = urllib.parse.urlsplit(value)
except ValueError as exc:
raise CredentialValidationError(
"GitLab OAuth profile issuer is invalid"
) from exc
if parsed.scheme not in {"http", "https"} or not parsed.hostname:
raise CredentialValidationError("GitLab OAuth profile issuer is invalid")
if parsed.username is not None or parsed.password is not None:
raise CredentialValidationError("GitLab OAuth profile issuer contains userinfo")
if parsed.path not in {"", "/"} or parsed.query or parsed.fragment:
raise CredentialValidationError(
"GitLab OAuth profile issuer must be origin-only"
)
hostname = parsed.hostname.lower()
if parsed.scheme == "http" and not (
hostname in {"localhost", "::1"} or hostname.startswith("127.")
):
raise CredentialValidationError("GitLab OAuth profile issuer must use HTTPS")
def validate_profile(profile: dict[str, Any]) -> None:
"""Validate a persisted OAuth profile."""
if not isinstance(profile, dict):
raise CredentialValidationError("GitLab OAuth profile must be an object")
missing = sorted(_REQUIRED_PROFILE_KEYS - profile.keys())
if missing:
raise CredentialValidationError(
f"GitLab OAuth profile missing keys: {', '.join(missing)}"
)
for key in ("issuer", "client_id", "access_token", "token_type"):
if not isinstance(profile[key], str) or not profile[key]:
raise CredentialValidationError(
f"GitLab OAuth profile {key!r} must be non-empty text"
)
_validate_issuer(cast(str, profile["issuer"]))
if not isinstance(profile["refresh_token"], str):
raise CredentialValidationError(
"GitLab OAuth profile 'refresh_token' must be text"
)
if not isinstance(profile["obtained_at"], int) or isinstance(
profile["obtained_at"],
bool,
):
raise CredentialValidationError(
"GitLab OAuth profile 'obtained_at' must be an integer"
)
if not isinstance(profile["expires_at"], int) or isinstance(
profile["expires_at"],
bool,
):
raise CredentialValidationError(
"GitLab OAuth profile 'expires_at' must be an integer"
)
if not isinstance(profile["scopes"], list) or not all(
isinstance(scope, str) and scope for scope in profile["scopes"]
):
raise CredentialValidationError(
"GitLab OAuth profile 'scopes' must be a text array"
)
if not isinstance(profile["usable"], bool):
raise CredentialValidationError("GitLab OAuth profile 'usable' must be boolean")
def _ensure_private_parent(path: pathlib.Path) -> None:
"""Create and verify the dedicated credential-store directory."""
if os.name == "nt":
raise CredentialSecurityError(
"GitLab OAuth profile persistence is unavailable on Windows until "
"a protected credential backend is configured"
)
previous_umask = os.umask(0o077)
try:
path.parent.mkdir(parents=True, exist_ok=True, mode=0o700)
finally:
os.umask(previous_umask)
info = path.parent.lstat()
if (
not stat.S_ISDIR(info.st_mode)
or info.st_uid != os.geteuid()
or info.st_mode & 0o077
):
raise CredentialSecurityError(
"GitLab OAuth token store directory must be owned by the user "
"without group or world permissions"
)
def _validate_descriptor(fd: int, *, label: str) -> None:
"""Validate ownership and permissions on an already-open descriptor."""
if os.name == "nt":
return
info = os.fstat(fd)
if (
not stat.S_ISREG(info.st_mode)
or info.st_uid != os.geteuid()
or info.st_mode & 0o077
):
raise CredentialSecurityError(
f"GitLab OAuth token store {label} must be owned by the user "
"without group or world permissions"
)
def load_store(path: pathlib.Path) -> dict[str, Any]:
"""Load and validate the OAuth profile store.
Args:
path: Profile-store path.
Returns:
Validated store envelope, or an empty envelope when the file is absent.
Raises:
CredentialSecurityError: The store cannot be opened safely or the
platform cannot protect persisted OAuth credentials.
CredentialValidationError: The store encoding, JSON, schema, or profile
content is malformed.
"""
if os.name == "nt":
_ensure_private_parent(path)
flags = os.O_RDONLY | getattr(os, "O_NOFOLLOW", 0)
try:
fd = os.open(path, flags)
except FileNotFoundError:
return {"schema_version": SCHEMA_VERSION, "profiles": {}}
except OSError as exc:
raise CredentialSecurityError(
"GitLab OAuth token store cannot be opened safely"
) from exc
raw_fd = fd
try:
_validate_descriptor(fd, label="file")
handle = os.fdopen(fd, "r", encoding="utf-8")
raw_fd = -1
with handle:
payload = json.load(handle)
except (UnicodeDecodeError, json.JSONDecodeError, RecursionError) as exc:
raise CredentialValidationError(
"GitLab OAuth token store is not valid JSON"
) from exc
finally:
if raw_fd >= 0:
os.close(raw_fd)
if not isinstance(payload, dict) or payload.get("schema_version") != SCHEMA_VERSION:
raise CredentialValidationError(
"GitLab OAuth token store has an unsupported schema"
)
profiles = payload.get("profiles")
if not isinstance(profiles, dict):
raise CredentialValidationError(
"GitLab OAuth token store profiles must be an object"
)
for name, profile in profiles.items():
validate_profile_name(name)
validate_profile(profile)
return payload
def save_store(path: pathlib.Path, payload: dict[str, Any]) -> None:
"""Atomically write the OAuth profile store with mode 0600.
Args:
path: Profile-store path.
payload: Validated store envelope.
Raises:
CredentialSecurityError: The platform or filesystem cannot provide the
required storage guarantees.
CredentialValidationError: The store envelope is malformed.
"""
if os.name == "nt":
_ensure_private_parent(path)
if not isinstance(payload, dict) or payload.get("schema_version") != SCHEMA_VERSION:
raise CredentialValidationError(
"GitLab OAuth token store has an unsupported schema"
)
profiles = payload.get("profiles")
if not isinstance(profiles, dict):
raise CredentialValidationError(
"GitLab OAuth token store profiles must be an object"
)
for name, profile in profiles.items():
validate_profile_name(name)
validate_profile(profile)
_ensure_private_parent(path)
previous_umask = os.umask(0o077)
temp_path: pathlib.Path | None = None
try:
fd, temp_name = tempfile.mkstemp(prefix=f".{path.name}.", dir=path.parent)
temp_path = pathlib.Path(temp_name)
try:
if os.name != "nt":
os.fchmod(fd, 0o600)
handle = os.fdopen(fd, "w", encoding="utf-8")
except BaseException:
os.close(fd)
raise
with handle:
json.dump(payload, handle, indent=2, sort_keys=True)
handle.write("\n")
handle.flush()
os.fsync(handle.fileno())
os.replace(temp_path, path)
temp_path = None
os.chmod(path, 0o600)
if os.name != "nt":
directory_fd = os.open(path.parent, os.O_RDONLY)
try:
os.fsync(directory_fd)
finally:
os.close(directory_fd)
except OSError as exc:
raise CredentialSecurityError(
"GitLab OAuth token store cannot be written safely"
) from exc
finally:
os.umask(previous_umask)
if temp_path is not None:
try:
temp_path.unlink(missing_ok=True)
except OSError:
pass
@contextmanager
def store_lock(path: pathlib.Path) -> Iterator[None]:
"""Serialize profile-store updates across processes.
Args:
path: Profile-store path whose sibling lock file is acquired.
Yields:
Control while the in-process and cross-process locks are held.
Raises:
CredentialSecurityError: Lock storage cannot be protected or no
supported locking primitive exists.
CredentialError: Cross-process lock acquisition exceeds its bounded
wait. The bound covers acquisition only; it does not bound waiting
for the in-process lock or work performed while the lock is held.
"""
with _PROCESS_LOCK:
_ensure_private_parent(path)
if _fcntl is None and _msvcrt is None:
raise CredentialSecurityError(
"no file-locking primitive is available; refusing an unlocked update"
)
lock_path = path.with_name(f"{path.name}.lock")
flags = os.O_RDWR | os.O_CREAT | getattr(os, "O_NOFOLLOW", 0)
previous_umask = os.umask(0o077)
try:
fd = os.open(lock_path, flags, 0o600)
except OSError as exc:
raise CredentialSecurityError(
"GitLab OAuth token store lock cannot be opened safely"
) from exc
finally:
os.umask(previous_umask)
acquired = False
try:
_validate_descriptor(fd, label="lock")
deadline = time.monotonic() + LOCK_ACQUISITION_TIMEOUT_SECONDS
while True:
try:
if _fcntl is not None: # pragma: no branch - one platform path
_fcntl.flock(fd, _fcntl.LOCK_EX | _fcntl.LOCK_NB)
elif _msvcrt is not None: # pragma: no cover - Windows
_msvcrt.locking(fd, _msvcrt.LK_NBLCK, 1)
acquired = True
break
except OSError as exc:
if _fcntl is not None and exc.errno not in _LOCK_CONTENTION_ERRNOS:
raise
remaining = deadline - time.monotonic()
if remaining <= 0:
raise CredentialError(
"timed out waiting for the GitLab OAuth token store lock"
) from None
time.sleep(min(LOCK_RETRY_INTERVAL_SECONDS, remaining))
yield
finally:
try:
if acquired and _fcntl is not None: # pragma: no branch
_fcntl.flock(fd, _fcntl.LOCK_UN)
elif acquired and _msvcrt is not None: # pragma: no cover - Windows
_msvcrt.locking(fd, _msvcrt.LK_UNLCK, 1)
finally:
os.close(fd)
def get_profile(store: dict[str, Any], name: str) -> Profile:
"""Return one named profile or raise a credential error."""
validate_profile_name(name)
profile = store.get("profiles", {}).get(name)
if not isinstance(profile, dict):
raise CredentialValidationError(
f"GitLab OAuth profile {name!r} does not exist; run auth login"
)
validate_profile(profile)
return cast(Profile, profile)
def set_profile(store: dict[str, Any], name: str, profile: Profile) -> None:
"""Set one validated profile in a mutable store envelope."""
validate_profile_name(name)
validate_profile(profile)
store.setdefault("profiles", {})[name] = profile
def delete_profile(store: dict[str, Any], name: str) -> bool:
"""Delete one profile and report whether it existed."""
validate_profile_name(name)
return store.setdefault("profiles", {}).pop(name, None) is not None
Requirements and compatibility
Written for: GitHub Copilot
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs an MCP server, Needs a command-line tool, Needs Python
The author says: Requires Python 3.11+. GitLab OAuth public-client credentials or explicit legacy-token mode.
Security
What our scanner noticed· Low risk
- Scripts that your agent may run
This skill includes scripts that your agent may run. Read them before you use it.
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Microsoft
- Publisher
- Microsoft (Official)
- Source
- microsoft/hve-core · .github/skills/project-planning/gitlab · commit f425e94
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Microsoft or Microsoft.
Get it from the source
8 of this skill’s files are not mirrored here, so there is no ZIP. Get the complete skill from its source: microsoft/hve-core