mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
Merge dev: STT feature, git date fixes, and session improvements (#82)
* fix session last active * Feature/sst (#81) * Use CSS field-sizing for textarea auto-height and abort STT recording on clear * Fix invalid date display in git commits * Use Unix timestamps for git log dates
This commit is contained in:
1 parent
21010956f7
commit
cb1714a4e0
17 files changed
+2475
-76
No files matched your search
@@ -61,8 +61,8 @@ describe('GitLogService', () => {
|
||||
getRepoByIdMock.mockReturnValue(mockRepo as any)
|
||||
executeCommandMock
|
||||
.mockResolvedValueOnce(
|
||||
'abc123|John Doe|john@example.com|2024-01-01 12:00:00 +0000|First commit\n' +
|
||||
'def456|Jane Smith|jane@example.com|2024-01-02 13:00:00 +0000|Second commit'
|
||||
'abc123|John Doe|john@example.com|1704110400|First commit\n' +
|
||||
'def456|Jane Smith|jane@example.com|1704200400|Second commit'
|
||||
)
|
||||
.mockResolvedValueOnce('')
|
||||
|
||||
@@ -70,7 +70,7 @@ describe('GitLogService', () => {
|
||||
|
||||
expect(getRepoByIdMock).toHaveBeenCalledWith(database, 1)
|
||||
expect(executeCommandMock).toHaveBeenCalledWith(
|
||||
['git', '-C', '/repos/test-repo', 'log', '--all', '-n', '10', '--format=%H|%an|%ae|%ai|%s'],
|
||||
['git', '-C', '/repos/test-repo', 'log', '--all', '-n', '10', '--format=%H|%an|%ae|%at|%s'],
|
||||
{ env: expect.any(Object) }
|
||||
)
|
||||
expect(result).toHaveLength(2)
|
||||
@@ -78,7 +78,7 @@ describe('GitLogService', () => {
|
||||
hash: 'abc123',
|
||||
authorName: 'John Doe',
|
||||
authorEmail: 'john@example.com',
|
||||
date: '2024-01-01 12:00:00 +0000',
|
||||
date: '1704110400',
|
||||
message: 'First commit',
|
||||
unpushed: false,
|
||||
})
|
||||
@@ -86,7 +86,7 @@ describe('GitLogService', () => {
|
||||
hash: 'def456',
|
||||
authorName: 'Jane Smith',
|
||||
authorEmail: 'jane@example.com',
|
||||
date: '2024-01-02 13:00:00 +0000',
|
||||
date: '1704200400',
|
||||
message: 'Second commit',
|
||||
unpushed: false,
|
||||
})
|
||||
@@ -99,13 +99,13 @@ describe('GitLogService', () => {
|
||||
}
|
||||
getRepoByIdMock.mockReturnValue(mockRepo as any)
|
||||
executeCommandMock
|
||||
.mockResolvedValueOnce('abc123|John Doe|john@example.com|2024-01-01 12:00:00 +0000|First commit')
|
||||
.mockResolvedValueOnce('abc123|John Doe|john@example.com|1704110400|First commit')
|
||||
.mockResolvedValueOnce('')
|
||||
|
||||
await service.getLog(1, database, 5)
|
||||
|
||||
expect(executeCommandMock).toHaveBeenCalledWith(
|
||||
['git', '-C', '/repos/test-repo', 'log', '--all', '-n', '5', '--format=%H|%an|%ae|%ai|%s'],
|
||||
['git', '-C', '/repos/test-repo', 'log', '--all', '-n', '5', '--format=%H|%an|%ae|%at|%s'],
|
||||
{ env: expect.any(Object) }
|
||||
)
|
||||
})
|
||||
@@ -117,7 +117,7 @@ describe('GitLogService', () => {
|
||||
}
|
||||
getRepoByIdMock.mockReturnValue(mockRepo as any)
|
||||
executeCommandMock
|
||||
.mockResolvedValueOnce('abc123|John Doe|john@example.com|2024-01-01 12:00:00 +0000|')
|
||||
.mockResolvedValueOnce('abc123|John Doe|john@example.com|1704110400|')
|
||||
.mockResolvedValueOnce('')
|
||||
|
||||
const result = await service.getLog(1, database, 10)
|
||||
@@ -133,7 +133,7 @@ describe('GitLogService', () => {
|
||||
}
|
||||
getRepoByIdMock.mockReturnValue(mockRepo as any)
|
||||
executeCommandMock
|
||||
.mockResolvedValueOnce('abc123|John Doe|john@example.com|2024-01-01 12:00:00 +0000|Multi|line commit')
|
||||
.mockResolvedValueOnce('abc123|John Doe|john@example.com|1704110400|Multi|line commit')
|
||||
.mockResolvedValueOnce('')
|
||||
|
||||
const result = await service.getLog(1, database, 10)
|
||||
@@ -164,7 +164,7 @@ describe('GitLogService', () => {
|
||||
}
|
||||
getRepoByIdMock.mockReturnValue(mockRepo as any)
|
||||
executeCommandMock
|
||||
.mockResolvedValueOnce('\n\nabc123|John Doe|john@example.com|2024-01-01 12:00:00 +0000|Test\n\n')
|
||||
.mockResolvedValueOnce('\n\nabc123|John Doe|john@example.com|1704110400|Test\n\n')
|
||||
.mockResolvedValueOnce('')
|
||||
|
||||
const result = await service.getLog(1, database, 10)
|
||||
@@ -180,7 +180,7 @@ describe('GitLogService', () => {
|
||||
}
|
||||
getRepoByIdMock.mockReturnValue(mockRepo as any)
|
||||
executeCommandMock
|
||||
.mockResolvedValueOnce('|John Doe|john@example.com|2024-01-01 12:00:00 +0000|No hash')
|
||||
.mockResolvedValueOnce('|John Doe|john@example.com|1704110400|No hash')
|
||||
.mockResolvedValueOnce('')
|
||||
|
||||
const result = await service.getLog(1, database, 10)
|
||||
@@ -204,6 +204,56 @@ describe('GitLogService', () => {
|
||||
|
||||
await expect(service.getLog(1, database, 10)).rejects.toThrow('Failed to get git log')
|
||||
})
|
||||
|
||||
it('handles commits with empty timestamps', async () => {
|
||||
const mockRepo = {
|
||||
id: 1,
|
||||
localPath: 'test-repo',
|
||||
}
|
||||
getRepoByIdMock.mockReturnValue(mockRepo as any)
|
||||
executeCommandMock
|
||||
.mockResolvedValueOnce(
|
||||
'abc123|John Doe|john@example.com|1704110400|Valid commit\n' +
|
||||
'def456|Jane Smith|jane@example.com||Empty timestamp\n'
|
||||
)
|
||||
.mockResolvedValueOnce('')
|
||||
|
||||
const result = await service.getLog(1, database, 10)
|
||||
|
||||
expect(result).toHaveLength(2)
|
||||
expect(result[0]).toEqual({
|
||||
hash: 'abc123',
|
||||
authorName: 'John Doe',
|
||||
authorEmail: 'john@example.com',
|
||||
date: '1704110400',
|
||||
message: 'Valid commit',
|
||||
unpushed: false,
|
||||
})
|
||||
expect(result[1]?.date).toBe('')
|
||||
})
|
||||
|
||||
it('handles commits with missing date field', async () => {
|
||||
const mockRepo = {
|
||||
id: 1,
|
||||
localPath: 'test-repo',
|
||||
}
|
||||
getRepoByIdMock.mockReturnValue(mockRepo as any)
|
||||
executeCommandMock
|
||||
.mockResolvedValueOnce('abc123|John Doe|john@example.com')
|
||||
.mockResolvedValueOnce('')
|
||||
|
||||
const result = await service.getLog(1, database, 10)
|
||||
|
||||
expect(result).toHaveLength(1)
|
||||
expect(result[0]).toEqual({
|
||||
hash: 'abc123',
|
||||
authorName: 'John Doe',
|
||||
authorEmail: 'john@example.com',
|
||||
date: '',
|
||||
message: '',
|
||||
unpushed: false,
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('getCommit', () => {
|
||||
@@ -213,20 +263,20 @@ describe('GitLogService', () => {
|
||||
localPath: 'test-repo',
|
||||
}
|
||||
getRepoByIdMock.mockReturnValue(mockRepo as any)
|
||||
executeCommandMock.mockResolvedValue('abc123|John Doe|john@example.com|2024-01-01 12:00:00 +0000|Test commit')
|
||||
executeCommandMock.mockResolvedValue('abc123|John Doe|john@example.com|1704110400|Test commit')
|
||||
|
||||
const result = await service.getCommit(1, 'abc123', database)
|
||||
|
||||
expect(getRepoByIdMock).toHaveBeenCalledWith(database, 1)
|
||||
expect(executeCommandMock).toHaveBeenCalledWith(
|
||||
['git', '-C', '/repos/test-repo', 'log', '--format=%H|%an|%ae|%ai|%s', 'abc123', '-1'],
|
||||
['git', '-C', '/repos/test-repo', 'log', '--format=%H|%an|%ae|%at|%s', 'abc123', '-1'],
|
||||
{ env: expect.any(Object) }
|
||||
)
|
||||
expect(result).toEqual({
|
||||
hash: 'abc123',
|
||||
authorName: 'John Doe',
|
||||
authorEmail: 'john@example.com',
|
||||
date: '2024-01-01 12:00:00 +0000',
|
||||
date: '1704110400',
|
||||
message: 'Test commit',
|
||||
})
|
||||
})
|
||||
@@ -263,7 +313,7 @@ describe('GitLogService', () => {
|
||||
localPath: 'test-repo',
|
||||
}
|
||||
getRepoByIdMock.mockReturnValue(mockRepo as any)
|
||||
executeCommandMock.mockResolvedValue('|John Doe|john@example.com|2024-01-01 12:00:00 +0000|Test')
|
||||
executeCommandMock.mockResolvedValue('|John Doe|john@example.com|1704110400|Test')
|
||||
|
||||
const result = await service.getCommit(1, 'abc123', database)
|
||||
|
||||
@@ -276,7 +326,7 @@ describe('GitLogService', () => {
|
||||
localPath: 'test-repo',
|
||||
}
|
||||
getRepoByIdMock.mockReturnValue(mockRepo as any)
|
||||
executeCommandMock.mockResolvedValue('abc123|John Doe|john@example.com|2024-01-01 12:00:00 +0000|')
|
||||
executeCommandMock.mockResolvedValue('abc123|John Doe|john@example.com|1704110400|')
|
||||
|
||||
const result = await service.getCommit(1, 'abc123', database)
|
||||
|
||||
|
||||
Reference in new issue
Block a user