feat: Implement glab-setup-git-identity - GitLab CLI based git identity setup#2
feat: Implement glab-setup-git-identity - GitLab CLI based git identity setup#2
Conversation
Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: #1
…ty setup This is the initial implementation similar to gh-setup-git-identity but for GitLab. Features: - Check GitLab CLI authentication status (isGlabAuthenticated) - Run interactive or token-based authentication (runGlabAuthLogin) - Get GitLab user information (getGitLabUsername, getGitLabEmail, getGitLabUserInfo) - Configure git user.name and user.email from GitLab account (setupGitIdentity) - Support for global and local git config scopes - Dry-run mode for previewing changes - Support for self-hosted GitLab instances via hostname option - Full TypeScript type definitions included Fixes #1 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The glab-setup-git-identity library needs to spawn git and glab commands, which requires the --allow-run flag for Deno. It also needs access to environment variables which requires --allow-env. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This reverts commit 962bb53.
|
|
Make sure we do something like this: But we should not depend on specific way of installation of And do support exactly all features of https://github.com/link-foundation/gh-setup-git-identity So it should do login or check of status: If possible we should also be able to configure login permissions. And we surely need to end with actual identity setup, based on user details from |
|
🤖 AI Work Session Started Starting automated work session at 2026-01-13T21:07:39.546Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait working session to finish, and provide your feedback. |
Add git credential helper configuration functionality equivalent to `gh auth setup-git` for GitHub CLI. This allows seamless HTTPS authentication when pushing/pulling to GitLab repositories. Features: - getGlabPath() - Dynamically detect glab installation path - runGlabAuthSetupGit() - Configure git credential helper for GitLab The implementation automatically detects the glab executable location (works with any installation method: Homebrew, apt, npm, etc.) and configures git to use `glab auth git-credential` as the credential helper for GitLab HTTPS URLs. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fix Deno test failures caused by resource leaks. The tests for getGlabPath and runGlabAuthSetupGit were creating promises that weren't properly awaited, causing Deno's leak detection to fail. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
✅ Implementation CompleteBased on the feedback, I've added the following features to match gh-setup-git-identity for GitLab: New Functions
How It WorksThe
This allows seamless HTTPS authentication when pushing/pulling to GitLab repositories, just like the GitHub version. Usage Exampleimport {
isGlabAuthenticated,
runGlabAuthLogin,
runGlabAuthSetupGit,
setupGitIdentity,
} from 'glab-setup-git-identity';
// 1. Check/run authentication
const authenticated = await isGlabAuthenticated();
if (!authenticated) {
await runGlabAuthLogin();
}
// 2. Configure git credential helper
await runGlabAuthSetupGit();
// Now git will use glab for authentication when pushing/pulling
// 3. Setup git identity
const { username, email } = await setupGitIdentity();CI Status
🤖 Generated with Claude Code |
|
Summary
This PR implements glab-setup-git-identity, a library for setting up git identity using GitLab CLI (glab) - similar to gh-setup-git-identity but for GitLab.
Features
Authentication management
isGlabAuthenticated()- Check if GitLab CLI is authenticatedrunGlabAuthLogin()- Run interactive or token-based authenticationrunGlabAuthSetupGit()- Configure git to use glab as credential helper (NEW)getGlabPath()- Detect glab installation path dynamically (NEW)User information retrieval
getGitLabUsername()- Get GitLab usernamegetGitLabEmail()- Get GitLab primary emailgetGitLabUserInfo()- Get both username and emailGit configuration
setGitConfig()- Set git config valuesgetGitConfig()- Get git config valuessetupGitIdentity()- Configure git identity from GitLab accountverifyGitIdentity()- Verify current git identityAdditional features
hostnameoptionGit Credential Helper Setup
The new
runGlabAuthSetupGit()function configures git to use glab for HTTPS authentication:This is equivalent to setting up:
The path to glab is detected automatically, so it works regardless of how glab was installed.
Issue Reference
Fixes #1
Test Plan
defaultAuthOptionsverify correct defaultsgetGitConfigverify null return for non-existent keyssetGitConfigverify setting and retrieving valuesverifyGitIdentityverify returned object structuregetGlabPathverify function exists and returns promiserunGlabAuthSetupGitverify function exists and returns promiseNote: Integration tests for GitLab API functions require authenticated glab CLI environment.
🤖 Generated with Claude Code