本文整理汇总了TypeScript中dugite.GitProcess类的典型用法代码示例。如果您正苦于以下问题:TypeScript GitProcess类的具体用法?TypeScript GitProcess怎么用?TypeScript GitProcess使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GitProcess类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: it
it('can discard a renamed file', async () => {
const repo = await setupEmptyRepository()
const gitStore = new GitStore(repo, shell)
const file = 'README.md'
const renamedFile = 'NEW-README.md'
const filePath = Path.join(repo.path, file)
Fs.writeFileSync(filePath, 'SOME WORDS GO HERE\n')
// commit the file, and then rename it
await GitProcess.exec(['add', file], repo.path)
await GitProcess.exec(['commit', '-m', 'added file'], repo.path)
await GitProcess.exec(['mv', file, renamedFile], repo.path)
const statusBeforeDiscard = await getStatus(repo)
const filesToDiscard = statusBeforeDiscard.workingDirectory.files
// discard the renamed file
await gitStore.discardChanges(filesToDiscard)
const status = await getStatus(repo)
const files = status.workingDirectory.files
expect(files.length).to.equal(0)
})
开发者ID:tamdao,项目名称:desktop,代码行数:26,代码来源:git-store-test.ts
示例2: it
it('can commit renames with modifications', async () => {
const repo = await setupEmptyRepository()
await FSE.writeFile(path.join(repo.path, 'foo'), 'foo\n')
await GitProcess.exec(['add', 'foo'], repo.path)
await GitProcess.exec(['commit', '-m', 'Initial commit'], repo.path)
await GitProcess.exec(['mv', 'foo', 'bar'], repo.path)
await FSE.writeFile(path.join(repo.path, 'bar'), 'bar\n')
const status = await getStatusOrThrow(repo)
const files = status.workingDirectory.files
expect(files.length).toEqual(1)
const sha = await createCommit(repo, 'renamed a file', [
files[0].withIncludeAll(true),
])
expect(sha).toHaveLength(7)
const statusAfter = await getStatusOrThrow(repo)
expect(statusAfter.workingDirectory.files.length).toEqual(0)
expect(statusAfter.currentTip!.substring(0, 7)).toEqual(sha)
})
开发者ID:ghmoore,项目名称:desktop,代码行数:26,代码来源:commit-test.ts
示例3: it
it('can commit when a delete is staged and the untracked file exists', async () => {
let status,
files = null
const repo = await setupEmptyRepository()
const firstPath = path.join(repo.path, 'first')
fs.writeFileSync(firstPath, 'line1\n')
await GitProcess.exec(['add', 'first'], repo.path)
await GitProcess.exec(['commit', '-am', 'commit first file'], repo.path)
await GitProcess.exec(['rm', '--cached', 'first'], repo.path)
// if the text is now different, everything is fine
fs.writeFileSync(firstPath, 'line2\n')
status = await getStatus(repo)
files = status.workingDirectory.files
expect(files.length).to.equal(1)
expect(files[0].path).to.contain('first')
expect(files[0].status).to.equal(AppFileStatus.New)
const toCommit = status.workingDirectory.withIncludeAllFiles(true)
await createCommit(repo, 'commit again!', toCommit.files)
status = await getStatus(repo)
files = status.workingDirectory.files
expect(files).to.be.empty
const commit = await getCommit(repo, 'HEAD')
expect(commit).to.not.be.null
expect(commit!.summary).to.equal('commit again!')
})
开发者ID:Ahskys,项目名称:desktop,代码行数:35,代码来源:commit-test.ts
示例4: it
it('only shows modifications after move for a renamed and modified file', async () => {
const repo = await setupEmptyRepository()
fs.writeFileSync(path.join(repo.path, 'foo'), 'foo\n')
await GitProcess.exec(['add', 'foo'], repo.path)
await GitProcess.exec(['commit', '-m', 'Initial commit'], repo.path)
await GitProcess.exec(['mv', 'foo', 'bar'], repo.path)
fs.writeFileSync(path.join(repo.path, 'bar'), 'bar\n')
const status = await getStatus(repo)
const files = status.workingDirectory.files
expect(files.length).to.equal(1)
const diff = await getTextDiff(repo, files[0])
expect(diff.hunks.length).to.equal(1)
const first = diff.hunks[0]
expect(first.lines.length).to.equal(3)
expect(first.lines[1].text).to.equal('-foo')
expect(first.lines[2].text).to.equal('+bar')
})
开发者ID:Ahskys,项目名称:desktop,代码行数:25,代码来源:diff-test.ts
示例5: it
it('when autocrlf=true and safecrlf=true, appends CRLF to file', async () => {
const repo = await setupEmptyRepository()
await GitProcess.exec(
['config', '--local', 'core.autocrlf', 'true'],
repo.path
)
await GitProcess.exec(
['config', '--local', 'core.safecrlf', 'true'],
repo.path
)
const path = repo.path
await saveGitIgnore(repo, 'node_modules')
await GitProcess.exec(['add', '.gitignore'], path)
const commit = await GitProcess.exec(
['commit', '-m', 'create the ignore file'],
path
)
expect(commit.exitCode).to.equal(0)
const contents = await readGitIgnoreAtRoot(repo)
expect(contents!.endsWith('\r\n'))
})
开发者ID:ghmoore,项目名称:desktop,代码行数:26,代码来源:gitignore-test.ts
示例6: it
it('reflects copies', async () => {
const testRepoPath = await setupFixtureRepository(
'copy-detection-status'
)
repository = new Repository(testRepoPath, -1, null, false)
// Git 2.18 now uses a new config value to handle detecting copies, so
// users who have this enabled will see this. For reference, Desktop does
// not enable this by default.
await GitProcess.exec(
['config', '--local', 'status.renames', 'copies'],
repository.path
)
await GitProcess.exec(['add', '.'], repository.path)
const status = await getStatusOrThrow(repository)
const files = status.workingDirectory.files
expect(files).toHaveLength(2)
expect(files[0].status.kind).toBe(AppFileStatusKind.Modified)
expect(files[0].path).toBe('CONTRIBUTING.md')
expect(files[1].path).toBe('docs/OVERVIEW.md')
expect(files[1].status).toEqual({
kind: AppFileStatusKind.Copied,
oldPath: 'CONTRIBUTING.md',
})
})
开发者ID:ghmoore,项目名称:desktop,代码行数:30,代码来源:status-test.ts
示例7: setupConflictedRepoWithMultipleFiles
export async function setupConflictedRepoWithMultipleFiles(): Promise<
Repository
> {
const repo = await setupEmptyRepository()
const filePaths = [
Path.join(repo.path, 'foo'),
Path.join(repo.path, 'bar'),
Path.join(repo.path, 'baz'),
Path.join(repo.path, 'cat'),
]
await FSE.writeFile(filePaths[0], 'b0')
await FSE.writeFile(filePaths[1], 'b0')
await GitProcess.exec(
['add', Path.basename(filePaths[0]), Path.basename(filePaths[1])],
repo.path
)
await GitProcess.exec(['commit', '-m', 'Commit'], repo.path)
await GitProcess.exec(['branch', 'other-branch'], repo.path)
await FSE.writeFile(filePaths[0], 'b1')
await FSE.writeFile(filePaths[2], 'b1')
await FSE.writeFile(filePaths[3], 'b1')
await GitProcess.exec(['rm', Path.basename(filePaths[1])], repo.path)
await GitProcess.exec(
[
'add',
Path.basename(filePaths[0]),
Path.basename(filePaths[2]),
Path.basename(filePaths[3]),
],
repo.path
)
await GitProcess.exec(['commit', '-m', 'Commit'], repo.path)
await GitProcess.exec(['checkout', 'other-branch'], repo.path)
await FSE.writeFile(filePaths[0], 'b2')
await FSE.writeFile(filePaths[1], 'b2')
await FSE.writeFile(filePaths[2], 'b2')
await FSE.writeFile(filePaths[3], 'b2')
await GitProcess.exec(
[
'add',
Path.basename(filePaths[0]),
Path.basename(filePaths[1]),
Path.basename(filePaths[2]),
Path.basename(filePaths[3]),
],
repo.path
)
await GitProcess.exec(['commit', '-m', 'Commit'], repo.path)
await GitProcess.exec(['merge', 'master'], repo.path)
return repo
}
开发者ID:ghmoore,项目名称:desktop,代码行数:59,代码来源:repositories.ts
示例8: beforeEach
beforeEach(async () => {
await GitProcess.exec(
['config', '--add', '--global', key, 'first'],
__dirname
)
await GitProcess.exec(
['config', '--add', '--global', key, 'second'],
__dirname
)
})
开发者ID:Ahskys,项目名称:desktop,代码行数:10,代码来源:config-test.ts
注:本文中的dugite.GitProcess类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论