Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codeant-cli",
"version": "0.4.12",
"version": "0.4.13",
"description": "Code review CLI tool",
"type": "module",
"bin": {
Expand Down
11 changes: 7 additions & 4 deletions src/scm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,13 @@ export function detectRemote() {
export function detectRepoName() {
const origin = getOrigin();
if (!origin) return null;
// Handle SSH: git@github.com:owner/repo.git
// Handle HTTPS: https://github.com/owner/repo.git
const match = origin.match(/[/:]([\w.-]+(?:\/[\w.-]+)+?)(?:\.git)?$/);
return match ? match[1] : null;
// SSH: git@host:path/to/repo[.git]
const sshMatch = origin.match(/^(?:[^@]+@)?[^:]+:(.+?)(?:\.git)?$/);
if (sshMatch) return sshMatch[1];
// HTTPS: https://[user:pass@]host/path/to/repo[.git]
const httpsMatch = origin.match(/^(?:https?|git):\/\/[^/]+\/(.+?)(?:\.git)?$/);
if (httpsMatch) return httpsMatch[1];
return null;
}

// Auto-detect default branch
Expand Down