mirror of
https://github.com/desktop/desktop
synced 2024-09-19 08:02:22 +00:00
Rename old "files"-like properties to "changesetData"
This commit is contained in:
parent
d7470a3cba
commit
baec65532c
|
@ -1326,10 +1326,10 @@ export class AppStore extends TypedBaseStore<IAppState> {
|
|||
}
|
||||
|
||||
const gitStore = this.gitStoreCache.get(repository)
|
||||
const changedFiles = await gitStore.performFailableOperation(() =>
|
||||
const changesetData = await gitStore.performFailableOperation(() =>
|
||||
getChangedFiles(repository, currentSHAs[0])
|
||||
)
|
||||
if (!changedFiles) {
|
||||
if (!changesetData) {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1349,13 +1349,13 @@ export class AppStore extends TypedBaseStore<IAppState> {
|
|||
const noFileSelected = commitSelection.file === null
|
||||
|
||||
const firstFileOrDefault =
|
||||
noFileSelected && changedFiles.files.length
|
||||
? changedFiles.files[0]
|
||||
noFileSelected && changesetData.files.length
|
||||
? changesetData.files[0]
|
||||
: commitSelection.file
|
||||
|
||||
this.repositoryStateCache.updateCommitSelection(repository, () => ({
|
||||
file: firstFileOrDefault,
|
||||
changesetData: changedFiles,
|
||||
changesetData: changesetData,
|
||||
diff: null,
|
||||
}))
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import { IChangesetData } from '../../lib/git'
|
|||
interface ICommitSummaryProps {
|
||||
readonly repository: Repository
|
||||
readonly commit: Commit
|
||||
readonly files: IChangesetData
|
||||
readonly changesetData: IChangesetData
|
||||
readonly emoji: Map<string, string>
|
||||
|
||||
/**
|
||||
|
@ -290,7 +290,7 @@ export class CommitSummary extends React.Component<
|
|||
}
|
||||
|
||||
public render() {
|
||||
const fileCount = this.props.files.files.length
|
||||
const fileCount = this.props.changesetData.files.length
|
||||
const filesPlural = fileCount === 1 ? 'file' : 'files'
|
||||
const filesDescription = `${fileCount} changed ${filesPlural}`
|
||||
const shortSHA = this.props.commit.shortSha
|
||||
|
@ -382,8 +382,8 @@ export class CommitSummary extends React.Component<
|
|||
}
|
||||
|
||||
private renderLinesChanged() {
|
||||
const linesAdded = this.props.files.linesAdded
|
||||
const linesDeleted = this.props.files.linesDeleted
|
||||
const linesAdded = this.props.changesetData.linesAdded
|
||||
const linesDeleted = this.props.changesetData.linesDeleted
|
||||
if (linesAdded + linesDeleted === 0) {
|
||||
return null
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ export class SelectedCommit extends React.Component<
|
|||
return (
|
||||
<CommitSummary
|
||||
commit={commit}
|
||||
files={this.props.changesetData}
|
||||
changesetData={this.props.changesetData}
|
||||
emoji={this.props.emoji}
|
||||
repository={this.props.repository}
|
||||
onExpandChanged={this.onExpandChanged}
|
||||
|
|
|
@ -187,9 +187,9 @@ describe('git/commit', () => {
|
|||
expect(newTip.shortSha).toEqual(sha)
|
||||
|
||||
// verify that the contents of this new commit are just the new file
|
||||
const changedFiles = await getChangedFiles(repository, newTip.sha)
|
||||
expect(changedFiles.files.length).toEqual(1)
|
||||
expect(changedFiles.files[0].path).toEqual(newFileName)
|
||||
const changesetData = await getChangedFiles(repository, newTip.sha)
|
||||
expect(changesetData.files.length).toEqual(1)
|
||||
expect(changesetData.files[0].path).toEqual(newFileName)
|
||||
|
||||
// verify that changes remain for this new file
|
||||
const status = await getStatusOrThrow(repository)
|
||||
|
@ -239,9 +239,9 @@ describe('git/commit', () => {
|
|||
expect(newTip.summary).toEqual('title')
|
||||
|
||||
// verify that the contents of this new commit are just the modified file
|
||||
const changedFiles = await getChangedFiles(repository, newTip.sha)
|
||||
expect(changedFiles.files.length).toEqual(1)
|
||||
expect(changedFiles.files[0].path).toEqual(modifiedFile)
|
||||
const changesetData = await getChangedFiles(repository, newTip.sha)
|
||||
expect(changesetData.files.length).toEqual(1)
|
||||
expect(changesetData.files[0].path).toEqual(modifiedFile)
|
||||
|
||||
// verify that changes remain for this modified file
|
||||
const status = await getStatusOrThrow(repository)
|
||||
|
@ -294,9 +294,9 @@ describe('git/commit', () => {
|
|||
expect(newTip.shortSha).toEqual(sha)
|
||||
|
||||
// verify that the contents of this new commit are just the modified file
|
||||
const changedFiles = await getChangedFiles(repository, newTip.sha)
|
||||
expect(changedFiles.files.length).toEqual(1)
|
||||
expect(changedFiles.files[0].path).toEqual(fileName)
|
||||
const changesetData = await getChangedFiles(repository, newTip.sha)
|
||||
expect(changesetData.files.length).toEqual(1)
|
||||
expect(changesetData.files[0].path).toEqual(fileName)
|
||||
})
|
||||
|
||||
it('can commit multiple hunks from modified file', async () => {
|
||||
|
@ -340,9 +340,9 @@ describe('git/commit', () => {
|
|||
expect(newTip.shortSha).toEqual(sha)
|
||||
|
||||
// verify that the contents of this new commit are just the modified file
|
||||
const changedFiles = await getChangedFiles(repository, newTip.sha)
|
||||
expect(changedFiles.files.length).toEqual(1)
|
||||
expect(changedFiles.files[0].path).toEqual(modifiedFile)
|
||||
const changesetData = await getChangedFiles(repository, newTip.sha)
|
||||
expect(changesetData.files.length).toEqual(1)
|
||||
expect(changesetData.files[0].path).toEqual(modifiedFile)
|
||||
|
||||
// verify that changes remain for this modified file
|
||||
const status = await getStatusOrThrow(repository)
|
||||
|
@ -382,9 +382,9 @@ describe('git/commit', () => {
|
|||
expect(newTip.sha.substring(0, 7)).toEqual(sha)
|
||||
|
||||
// verify that the contents of this new commit are just the new file
|
||||
const changedFiles = await getChangedFiles(repository, newTip.sha)
|
||||
expect(changedFiles.files.length).toEqual(1)
|
||||
expect(changedFiles.files[0].path).toEqual(deletedFile)
|
||||
const changesetData = await getChangedFiles(repository, newTip.sha)
|
||||
expect(changesetData.files.length).toEqual(1)
|
||||
expect(changesetData.files[0].path).toEqual(deletedFile)
|
||||
|
||||
// verify that changes remain for this new file
|
||||
const status = await getStatusOrThrow(repository)
|
||||
|
@ -838,10 +838,12 @@ describe('git/commit', () => {
|
|||
expect(beforeCommit.currentTip).not.toBe(afterCommit.currentTip)
|
||||
|
||||
// Verify the file was delete in repo
|
||||
const changedFiles = await getChangedFiles(repo, afterCommit.currentTip!)
|
||||
expect(changedFiles.files.length).toBe(2)
|
||||
expect(changedFiles.files[0].status.kind).toBe(AppFileStatusKind.Modified)
|
||||
expect(changedFiles.files[1].status.kind).toBe(AppFileStatusKind.Deleted)
|
||||
const changesetData = await getChangedFiles(repo, afterCommit.currentTip!)
|
||||
expect(changesetData.files.length).toBe(2)
|
||||
expect(changesetData.files[0].status.kind).toBe(
|
||||
AppFileStatusKind.Modified
|
||||
)
|
||||
expect(changesetData.files[1].status.kind).toBe(AppFileStatusKind.Deleted)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -61,13 +61,13 @@ describe('git/log', () => {
|
|||
|
||||
describe('getChangedFiles', () => {
|
||||
it('loads the files changed in the commit', async () => {
|
||||
const changedFiles = await getChangedFiles(
|
||||
const changesetData = await getChangedFiles(
|
||||
repository,
|
||||
'7cd6640e5b6ca8dbfd0b33d0281ebe702127079c'
|
||||
)
|
||||
expect(changedFiles.files).toHaveLength(1)
|
||||
expect(changedFiles.files[0].path).toBe('README.md')
|
||||
expect(changedFiles.files[0].status.kind).toBe(AppFileStatusKind.New)
|
||||
expect(changesetData.files).toHaveLength(1)
|
||||
expect(changesetData.files[0].path).toBe('README.md')
|
||||
expect(changesetData.files[0].status.kind).toBe(AppFileStatusKind.New)
|
||||
})
|
||||
|
||||
it('detects renames', async () => {
|
||||
|
@ -104,27 +104,29 @@ describe('git/log', () => {
|
|||
// ensure the test repository is configured to detect copies
|
||||
await setupLocalConfig(repository, [['diff.renames', 'copies']])
|
||||
|
||||
const changedFiles = await getChangedFiles(repository, 'a500bf415')
|
||||
expect(changedFiles.files).toHaveLength(2)
|
||||
const changesetData = await getChangedFiles(repository, 'a500bf415')
|
||||
expect(changesetData.files).toHaveLength(2)
|
||||
|
||||
expect(changedFiles.files[0].path).toBe('duplicate-with-edits.md')
|
||||
expect(changedFiles.files[0].status).toEqual({
|
||||
expect(changesetData.files[0].path).toBe('duplicate-with-edits.md')
|
||||
expect(changesetData.files[0].status).toEqual({
|
||||
kind: AppFileStatusKind.Copied,
|
||||
oldPath: 'initial.md',
|
||||
})
|
||||
|
||||
expect(changedFiles.files[1].path).toBe('duplicate.md')
|
||||
expect(changedFiles.files[1].status).toEqual({
|
||||
expect(changesetData.files[1].path).toBe('duplicate.md')
|
||||
expect(changesetData.files[1].status).toEqual({
|
||||
kind: AppFileStatusKind.Copied,
|
||||
oldPath: 'initial.md',
|
||||
})
|
||||
})
|
||||
|
||||
it('handles commit when HEAD exists on disk', async () => {
|
||||
const changedFiles = await getChangedFiles(repository, 'HEAD')
|
||||
expect(changedFiles.files).toHaveLength(1)
|
||||
expect(changedFiles.files[0].path).toBe('README.md')
|
||||
expect(changedFiles.files[0].status.kind).toBe(AppFileStatusKind.Modified)
|
||||
const changesetData = await getChangedFiles(repository, 'HEAD')
|
||||
expect(changesetData.files).toHaveLength(1)
|
||||
expect(changesetData.files[0].path).toBe('README.md')
|
||||
expect(changesetData.files[0].status.kind).toBe(
|
||||
AppFileStatusKind.Modified
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -290,9 +290,12 @@ describe('git/rebase', () => {
|
|||
|
||||
status = await getStatusOrThrow(repository)
|
||||
|
||||
const changedFiles = await getChangedFiles(repository, status.currentTip!)
|
||||
const changesetData = await getChangedFiles(
|
||||
repository,
|
||||
status.currentTip!
|
||||
)
|
||||
|
||||
filesInRebasedCommit = changedFiles.files
|
||||
filesInRebasedCommit = changesetData.files
|
||||
})
|
||||
|
||||
it('returns success', () => {
|
||||
|
|
|
@ -47,8 +47,13 @@ describe('git/cherry-pick', () => {
|
|||
expect(log.length).toBe(2)
|
||||
|
||||
// verify squashed commit contains changes from squashed commits
|
||||
const squashedFiles = await getChangedFiles(repository, squashed.sha)
|
||||
const squashedFilePaths = squashedFiles.files.map(f => f.path).join(' ')
|
||||
const squashedChangesetData = await getChangedFiles(
|
||||
repository,
|
||||
squashed.sha
|
||||
)
|
||||
const squashedFilePaths = squashedChangesetData.files
|
||||
.map(f => f.path)
|
||||
.join(' ')
|
||||
expect(squashedFilePaths).toContain('first.md')
|
||||
expect(squashedFilePaths).toContain('second.md')
|
||||
})
|
||||
|
@ -91,8 +96,13 @@ describe('git/cherry-pick', () => {
|
|||
expect(log.length).toBe(2)
|
||||
|
||||
// verify squashed commit contains changes from squashed commits
|
||||
const squashedFiles = await getChangedFiles(repository, squashed.sha)
|
||||
const squashedFilePaths = squashedFiles.files.map(f => f.path).join(' ')
|
||||
const squashedChangesetData = await getChangedFiles(
|
||||
repository,
|
||||
squashed.sha
|
||||
)
|
||||
const squashedFilePaths = squashedChangesetData.files
|
||||
.map(f => f.path)
|
||||
.join(' ')
|
||||
expect(squashedFilePaths).toContain('first.md')
|
||||
expect(squashedFilePaths).toContain('second.md')
|
||||
expect(squashedFilePaths).toContain('third.md')
|
||||
|
@ -123,8 +133,13 @@ describe('git/cherry-pick', () => {
|
|||
expect(log.length).toBe(1)
|
||||
|
||||
// verify squashed commit contains changes from squashed commits
|
||||
const squashedFiles = await getChangedFiles(repository, squashed.sha)
|
||||
const squashedFilePaths = squashedFiles.files.map(f => f.path).join(' ')
|
||||
const squashedChangesetData = await getChangedFiles(
|
||||
repository,
|
||||
squashed.sha
|
||||
)
|
||||
const squashedFilePaths = squashedChangesetData.files
|
||||
.map(f => f.path)
|
||||
.join(' ')
|
||||
expect(squashedFilePaths).toContain('initialize')
|
||||
expect(squashedFilePaths).toContain('first.md')
|
||||
expect(squashedFilePaths).toContain('second.md')
|
||||
|
@ -169,8 +184,13 @@ describe('git/cherry-pick', () => {
|
|||
expect(log.length).toBe(4)
|
||||
|
||||
// verify squashed commit contains changes from squashed commits
|
||||
const squashedFiles = await getChangedFiles(repository, squashed.sha)
|
||||
const squashedFilePaths = squashedFiles.files.map(f => f.path).join(' ')
|
||||
const squashedChangesetData = await getChangedFiles(
|
||||
repository,
|
||||
squashed.sha
|
||||
)
|
||||
const squashedFilePaths = squashedChangesetData.files
|
||||
.map(f => f.path)
|
||||
.join(' ')
|
||||
expect(squashedFilePaths).toContain('first.md')
|
||||
expect(squashedFilePaths).toContain('third.md')
|
||||
expect(squashedFilePaths).toContain('fifth.md')
|
||||
|
@ -257,8 +277,13 @@ describe('git/cherry-pick', () => {
|
|||
expect(squashed.body).toBe('Test Body\n')
|
||||
|
||||
// verify squashed commit contains changes from squashed commits
|
||||
const squashedFiles = await getChangedFiles(repository, squashed.sha)
|
||||
const squashedFilePaths = squashedFiles.files.map(f => f.path).join(' ')
|
||||
const squashedChangesetData = await getChangedFiles(
|
||||
repository,
|
||||
squashed.sha
|
||||
)
|
||||
const squashedFilePaths = squashedChangesetData.files
|
||||
.map(f => f.path)
|
||||
.join(' ')
|
||||
expect(squashedFilePaths).toContain('first.md')
|
||||
expect(squashedFilePaths).toContain('second.md')
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue