@@ -2927,6 +2927,20 @@ class GitGraphView {
29272927 sendMessage ( { command : 'copyFilePath' , repo : this . currentRepo , filePath : file . newFilePath , absolute : absolute } ) ;
29282928 } ;
29292929
2930+ const triggerResetFileToRevision = ( file : GG . GitFileChange , fileElem : HTMLElement ) => {
2931+ const expandedCommit = this . expandedCommit ;
2932+ if ( expandedCommit === null ) return ;
2933+
2934+ const commitHash = getCommitHashForFile ( file , expandedCommit ) ;
2935+ dialog . showConfirmation ( 'Are you sure you want to reset <b><i>' + escapeHtml ( file . newFilePath ) + '</i></b> to it\'s state at commit <b><i>' + abbrevCommit ( commitHash ) + '</i></b>? Any uncommitted changes made to this file will be overwritten.' , 'Yes, reset file' , ( ) => {
2936+ runAction ( { command : 'resetFileToRevision' , repo : this . currentRepo , commitHash : commitHash , filePath : file . newFilePath } , 'Resetting file' ) ;
2937+ } , {
2938+ type : TargetType . CommitDetailsView ,
2939+ hash : commitHash ,
2940+ elem : fileElem
2941+ } ) ;
2942+ } ;
2943+
29302944 const triggerViewFileAtRevision = ( file : GG . GitFileChange , fileElem : HTMLElement ) => {
29312945 const expandedCommit = this . expandedCommit ;
29322946 if ( expandedCommit === null ) return ;
@@ -3024,7 +3038,8 @@ class GitGraphView {
30243038 elem : fileElem
30253039 } ;
30263040 const diffPossible = file . type === GG . GitFileStatus . Untracked || ( file . additions !== null && file . deletions !== null ) ;
3027- const fileExistsAtThisRevisionAndDiffPossible = file . type !== GG . GitFileStatus . Deleted && diffPossible && ! isUncommitted ;
3041+ const fileExistsAtThisRevision = file . type !== GG . GitFileStatus . Deleted && ! isUncommitted ;
3042+ const fileExistsAtThisRevisionAndDiffPossible = fileExistsAtThisRevision && diffPossible ;
30283043 const codeReviewInProgressAndNotReviewed = expandedCommit . codeReview !== null && expandedCommit . codeReview . remainingFiles . includes ( file . newFilePath ) ;
30293044
30303045 contextMenu . show ( [
@@ -3062,6 +3077,13 @@ class GitGraphView {
30623077 onClick : ( ) => this . cdvUpdateFileState ( file , fileElem , false , false )
30633078 }
30643079 ] ,
3080+ [
3081+ {
3082+ title : 'Reset File to this Revision' + ELLIPSIS ,
3083+ visible : fileExistsAtThisRevision && expandedCommit . compareWithHash === null ,
3084+ onClick : ( ) => triggerResetFileToRevision ( file , fileElem )
3085+ }
3086+ ] ,
30653087 [
30663088 {
30673089 title : 'Copy Absolute File Path to Clipboard' ,
@@ -3343,6 +3365,9 @@ window.addEventListener('load', () => {
33433365 case 'renameBranch' :
33443366 refreshOrDisplayError ( msg . error , 'Unable to Rename Branch' ) ;
33453367 break ;
3368+ case 'resetFileToRevision' :
3369+ refreshOrDisplayError ( msg . error , 'Unable to Reset File to Revision' ) ;
3370+ break ;
33463371 case 'resetToCommit' :
33473372 refreshOrDisplayError ( msg . error , 'Unable to Reset to Commit' ) ;
33483373 break ;
0 commit comments