feat: initialize project structure with essential files and configurations
- Add .gitignore to exclude unnecessary files and directories - Create .npmrc for npm authentication - Add AGENTS.md for project documentation - Initialize package.json with project metadata and dependencies - Implement app.ts to set up the application and project manager - Create file-search module for searching files in a directory - Set up project manager and listener for managing project files - Implement project search functionality with MeiliSearch integration - Add routes for authentication and project management - Create scheduler for task management - Add tests for file searching and project management functionalities
This commit is contained in:
16
src/project/util/git.ts
Normal file
16
src/project/util/git.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { execSync } from 'node:child_process'
|
||||
|
||||
export const getGitPathname = (repoPath: string): string | null => {
|
||||
try {
|
||||
const url = execSync('git config --get remote.origin.url', { cwd: repoPath, encoding: 'utf-8' }).trim();
|
||||
if (url) {
|
||||
const _url = new URL(url.replace(/\.git$/, ''));
|
||||
const pathname = _url.pathname.replace(/^\/+/, '').replace(/\/+$/, ''); // 去除开头和结尾的斜杠
|
||||
return pathname;
|
||||
}
|
||||
return null;
|
||||
} catch (err) {
|
||||
console.error(`Failed to get remote URL for repo at ${repoPath}:`, err);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user