File tree Expand file tree Collapse file tree 4 files changed +36
-0
lines changed
Expand file tree Collapse file tree 4 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,13 @@ export const getFileAtHeadInput = z.object({
120120} ) ;
121121export const getFileAtHeadOutput = z . string ( ) . nullable ( ) ;
122122
123+ // getDiffHead schemas
124+ export const getDiffHeadInput = z . object ( {
125+ directoryPath : z . string ( ) ,
126+ ignoreWhitespace : z . boolean ( ) . optional ( ) ,
127+ } ) ;
128+ export const getDiffHeadOutput = z . string ( ) ;
129+
123130// getDiffStats schemas
124131export const getDiffStatsInput = directoryPathInput ;
125132export const getDiffStatsOutput = diffStatsSchema ;
Original file line number Diff line number Diff line change 99 getCurrentBranch ,
1010 getDefaultBranch ,
1111 getDiffAgainstRemote ,
12+ getDiffHead ,
1213 getDiffStats ,
1314 getFileAtHead ,
1415 getLatestCommit ,
@@ -275,6 +276,13 @@ export class GitService extends TypedEventEmitter<GitServiceEvents> {
275276 return getFileAtHead ( directoryPath , filePath ) ;
276277 }
277278
279+ public async getDiffHead (
280+ directoryPath : string ,
281+ ignoreWhitespace ?: boolean ,
282+ ) : Promise < string > {
283+ return getDiffHead ( directoryPath , { ignoreWhitespace } ) ;
284+ }
285+
278286 public async getDiffStats ( directoryPath : string ) : Promise < DiffStats > {
279287 const stats = await getDiffStats ( directoryPath , {
280288 excludePatterns : [ ".claude" , "CLAUDE.local.md" ] ,
Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ import {
2929 getCommitConventionsOutput ,
3030 getCurrentBranchInput ,
3131 getCurrentBranchOutput ,
32+ getDiffHeadInput ,
33+ getDiffHeadOutput ,
3234 getDiffStatsInput ,
3335 getDiffStatsOutput ,
3436 getFileAtHeadInput ,
@@ -136,6 +138,13 @@ export const gitRouter = router({
136138 getService ( ) . getFileAtHead ( input . directoryPath , input . filePath ) ,
137139 ) ,
138140
141+ getDiffHead : publicProcedure
142+ . input ( getDiffHeadInput )
143+ . output ( getDiffHeadOutput )
144+ . query ( ( { input } ) =>
145+ getService ( ) . getDiffHead ( input . directoryPath , input . ignoreWhitespace ) ,
146+ ) ,
147+
139148 getDiffStats : publicProcedure
140149 . input ( getDiffStatsInput )
141150 . output ( getDiffStatsOutput )
Original file line number Diff line number Diff line change @@ -935,6 +935,18 @@ export async function getUnstagedDiff(
935935 } ) ;
936936}
937937
938+ export async function getDiffHead (
939+ baseDir : string ,
940+ options ?: CreateGitClientOptions & { ignoreWhitespace ?: boolean } ,
941+ ) : Promise < string > {
942+ const manager = getGitOperationManager ( ) ;
943+ const args = [ "HEAD" ] ;
944+ if ( options ?. ignoreWhitespace ) args . push ( "--ignore-all-space" ) ;
945+ return manager . executeRead ( baseDir , ( git ) => git . diff ( args ) , {
946+ signal : options ?. abortSignal ,
947+ } ) ;
948+ }
949+
938950export async function getDiffAgainstRemote (
939951 baseDir : string ,
940952 baseBranch : string ,
You can’t perform that action at this time.
0 commit comments