feat(git): enhance token authentication and credential handling

This commit is contained in:
Bohdan Triapitsyn
2026-01-14 02:54:48 +02:00
parent fa83c1e645
commit 1319033df9
7 changed files with 11 additions and 56 deletions
@@ -73,18 +73,16 @@ export const GitIdentitiesPage: React.FC = () => {
React.useEffect(() => {
if (importData) {
// Pre-fill from imported credential
// For repo-specific hosts like "github.com/user/repo", use just "repo" as name
const parts = importData.host.split('/');
const displayName = parts.length >= 3 ? parts[parts.length - 1] : importData.host;
setName(displayName);
setUserName(importData.username);
setUserEmail('');
setAuthType('token');
setSshKey('');
setHost(importData.host);
setColor('string'); // cyan for token-based
setColor('string');
setIcon('code');
} else if (isNewProfile) {
setName('');
@@ -300,18 +300,11 @@ interface DiscoveredCredentialItemProps {
onImport: () => void;
}
/**
* Get display name for a credential host.
* For repo-specific hosts like "github.com/user/repo", returns just "repo".
* For host-only like "github.com", returns "github.com".
*/
const getCredentialDisplayName = (host: string): string => {
const parts = host.split('/');
if (parts.length >= 3) {
// repo-specific: github.com/user/repo -> repo
return parts[parts.length - 1];
}
// host-only: github.com
return host;
};