-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #100: Add purge support #104
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -585,6 +585,50 @@ export class CommandCenter { | |
} | ||
} | ||
|
||
@command('hg.purgeFiles', { repository: true }) | ||
async purgeFiles(repository: Repository): Promise<void> { | ||
return this._purge(repository.untrackedGroup.resources); | ||
} | ||
|
||
@command('hg.purgeAll', { repository: true }) | ||
async purgeAll(repository: Repository): Promise<void> { | ||
if (await interaction.confirmDeleteUntrackedAndIgnored()) { | ||
return await repository.purgeAll(); | ||
} | ||
} | ||
|
||
@command('hg.purge') | ||
async purge(...resourceStates: SourceControlResourceState[]): Promise<void> { | ||
if (resourceStates.length === 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why should there be an option to purge specific files? Selecting specific files to send to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, you're right. Currently there is no way of deleting untracked files from the SCM tab, so this is what I am implementing. |
||
const resource = this.getSCMResource(); | ||
|
||
if (!resource) { | ||
return; | ||
} | ||
|
||
resourceStates = [resource]; | ||
} | ||
|
||
const scmResources = resourceStates | ||
.filter(s => s instanceof Resource && s.resourceGroup instanceof UntrackedGroup) as Resource[]; | ||
return this._purge(scmResources); | ||
} | ||
|
||
private async _purge(scmResources: Resource[]): Promise<void> { | ||
if (!scmResources.length) { | ||
return; | ||
} | ||
|
||
const fileNames = scmResources.map(r => path.basename(r.resourceUri.fsPath)); | ||
const confirmed = await interaction.confirmDeleteFiles(fileNames); | ||
if (!confirmed) { | ||
return; | ||
} | ||
|
||
const resources = scmResources.map(r => r.resourceUri); | ||
await this.runByRepository(resources, async (repository, uris) => repository.purge(...uris)); | ||
} | ||
|
||
private async smartCommit(repository: Repository, getCommitMessage: () => Promise<string | undefined>, opts: CommitOptions = {}): Promise<boolean> { | ||
// validate no conflicts | ||
const numConflictResources = repository.conflictGroup.resources.length; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the difference between "Purge" and "Purge All Untracked Files"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Purge is for the individual file, and Purge all untracked is for the whole untracked files source group.
This allow the user to have a fine grain control on the Untracked Source Group view.