forked from qt-creator/qt-creator
		
	Git: Introduce Recover Deleted Files action
Change-Id: I913c07522a8ca82366fd142597430c02e53faa27 Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
		
				
					committed by
					
						
						Orgad Shaneh
					
				
			
			
				
	
			
			
			
						parent
						
							b1239d6c4c
						
					
				
				
					commit
					a8ddaafca4
				
			@@ -993,6 +993,23 @@ void GitClient::reset(const QString &workingDirectory, const QString &argument,
 | 
			
		||||
    vcsExec(workingDirectory, arguments, nullptr, true, flags);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GitClient::recoverDeletedFiles(const QString &workingDirectory)
 | 
			
		||||
{
 | 
			
		||||
    const SynchronousProcessResponse response =
 | 
			
		||||
            vcsFullySynchronousExec(workingDirectory, {"ls-files", "--deleted"},
 | 
			
		||||
                                    VcsCommand::SuppressCommandLogging);
 | 
			
		||||
    if (response.result == SynchronousProcessResponse::Finished) {
 | 
			
		||||
        const QString stdOut = response.stdOut().trimmed();
 | 
			
		||||
        if (stdOut.isEmpty()) {
 | 
			
		||||
            VcsOutputWindow::appendError(tr("Nothing to recover"));
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        const QStringList files = stdOut.split('\n');
 | 
			
		||||
        synchronousCheckoutFiles(workingDirectory, files, QString(), nullptr, false);
 | 
			
		||||
        VcsOutputWindow::append(tr("Files recovered"), VcsOutputWindow::Message);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GitClient::addFile(const QString &workingDirectory, const QString &fileName)
 | 
			
		||||
{
 | 
			
		||||
    vcsExec(workingDirectory, {"add", fileName});
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user