mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
fix: filter source control commits by branch (#286)
This commit is contained in:
1 parent
8d93f2f1f9
commit
bb1df259b6
6 files changed
+67
-11
No files matched your search
@@ -407,7 +407,8 @@ export function createRepoGitRoutes(database: Database, gitAuthService: GitAuthS
|
||||
}
|
||||
|
||||
const limit = parseInt(c.req.query('limit') || '10', 10)
|
||||
const commits = await git.getLog(id, database, limit)
|
||||
const branch = c.req.query('branch') || undefined
|
||||
const commits = await git.getLog(id, database, limit, branch)
|
||||
|
||||
return c.json({ commits })
|
||||
} catch (error: unknown) {
|
||||
|
||||
@@ -84,7 +84,7 @@ export class GitService {
|
||||
return this.getFileDiff(repoId, filePath, database, { includeStaged })
|
||||
}
|
||||
|
||||
async getLog(repoId: number, database: Database, limit: number = 10): Promise<GitCommit[]> {
|
||||
async getLog(repoId: number, database: Database, limit: number = 10, branch?: string): Promise<GitCommit[]> {
|
||||
try {
|
||||
const repo = getRepoById(database, repoId)
|
||||
if (!repo) {
|
||||
@@ -97,7 +97,7 @@ export class GitService {
|
||||
'-C',
|
||||
repoPath,
|
||||
'log',
|
||||
`--all`,
|
||||
branch?.trim() || 'HEAD',
|
||||
`-n`,
|
||||
String(limit),
|
||||
'--format=%H|%an|%ae|%at|%s'
|
||||
|
||||
Reference in new issue
Block a user