Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit c96687a

Browse files
authored
Merge pull request #1754 from atom/revert-1713-feature/commit-template
Revert "Feature: Add commit template support"
2 parents 4bc7fde + 519678d commit c96687a

32 files changed

+2
-147
lines changed

lib/get-repo-pipeline-manager.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,7 @@ export default function({confirm, notificationManager, workspace}) {
210210
commitPipeline.addMiddleware('failed-to-commit-error', async (next, repository) => {
211211
try {
212212
const result = await next();
213-
const message = await repository.getCommitMessageFromTemplate();
214-
repository.setCommitMessage(message || '');
213+
repository.setCommitMessage('');
215214
destroyFilePatchPaneItems({onlyStaged: true}, workspace);
216215
return result;
217216
} catch (error) {

lib/git-shell-out-strategy.js

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -415,33 +415,6 @@ export default class GitShellOutStrategy {
415415
return this.exec(args, {writeOperation: true});
416416
}
417417

418-
async getCommitMessageFromTemplate() {
419-
let templatePath = await this.getConfig('commit.template');
420-
if (!templatePath) {
421-
return '';
422-
}
423-
424-
/**
425-
* Get absolute path from git path
426-
* https://git-scm.com/docs/git-config#git-config-pathname
427-
*/
428-
const homeDir = os.homedir();
429-
const regex = new RegExp('^~([^/]*)/');
430-
templatePath = templatePath.trim().replace(regex, (_, user) => {
431-
return `${user ? path.join(path.dirname(homeDir), user) : homeDir}/`;
432-
});
433-
434-
if (!path.isAbsolute(templatePath)) {
435-
templatePath = path.join(this.workingDir, templatePath);
436-
}
437-
438-
if (!await fileExists(templatePath)) {
439-
return '';
440-
}
441-
const message = await fs.readFile(templatePath, {encoding: 'utf8'});
442-
return message.trim();
443-
}
444-
445418
unstageFiles(paths, commit = 'HEAD') {
446419
if (paths.length === 0) { return Promise.resolve(null); }
447420
const args = ['reset', commit, '--'].concat(paths.map(toGitPathSep));

lib/models/repository-states/present.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ export default class Present extends State {
4141
this.operationStates = new OperationStates({didUpdate: this.didUpdate.bind(this)});
4242

4343
this.commitMessage = '';
44-
this.setCommitMessageFromTemplate();
4544

4645
if (history) {
4746
this.discardHistory.updateHistory(history);
@@ -56,19 +55,6 @@ export default class Present extends State {
5655
return this.commitMessage;
5756
}
5857

59-
async setCommitMessageFromTemplate() {
60-
const message = await this.getCommitMessageFromTemplate();
61-
if (!message) {
62-
return;
63-
}
64-
this.setCommitMessage(message);
65-
this.didUpdate();
66-
}
67-
68-
async getCommitMessageFromTemplate() {
69-
return await this.git().getCommitMessageFromTemplate();
70-
}
71-
7258
getOperationStates() {
7359
return this.operationStates;
7460
}

lib/models/repository-states/state.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,6 @@ export default class State {
373373
return '';
374374
}
375375

376-
getCommitMessageFromTemplate() {
377-
return unsupportedOperationPromise(this, 'getCommitMessageFromTemplate');
378-
}
379-
380376
// Cache
381377

382378
getCache() {

lib/models/repository.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,6 @@ const delegates = [
358358

359359
'setCommitMessage',
360360
'getCommitMessage',
361-
'getCommitMessageFromTemplate',
362361
'getCache',
363362
];
364363

test/controllers/commit-controller.test.js

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ describe('CommitController', function() {
6060
const repository1 = await buildRepository(workdirPath1);
6161
const workdirPath2 = await cloneRepository('three-files');
6262
const repository2 = await buildRepository(workdirPath2);
63-
const workdirPath3 = await cloneRepository('commit-template');
64-
const repository3 = await buildRepository(workdirPath3);
65-
const templateCommitMessage = await repository3.git.getCommitMessageFromTemplate();
6663

6764
app = React.cloneElement(app, {repository: repository1});
6865
const wrapper = shallow(app, {disableLifecycleMethods: true});
@@ -77,23 +74,8 @@ describe('CommitController', function() {
7774

7875
wrapper.setProps({repository: repository1});
7976
assert.equal(wrapper.instance().getCommitMessage(), 'message 1');
80-
wrapper.setProps({repository: repository3});
81-
await assert.async.strictEqual(wrapper.instance().getCommitMessage(), templateCommitMessage);
8277
});
8378

84-
85-
describe('when commit.template config is set', function() {
86-
it('populates the commit message with the template', async function() {
87-
const workdirPath = await cloneRepository('commit-template');
88-
const repository = await buildRepository(workdirPath);
89-
const templateCommitMessage = await repository.git.getCommitMessageFromTemplate();
90-
app = React.cloneElement(app, {repository});
91-
const wrapper = shallow(app, {disableLifecycleMethods: true});
92-
await assert.async.strictEqual(wrapper.instance().getCommitMessage(), templateCommitMessage);
93-
});
94-
});
95-
96-
9779
describe('the passed commit message', function() {
9880
let repository;
9981

@@ -158,21 +140,6 @@ describe('CommitController', function() {
158140
assert.strictEqual(repository.getCommitMessage(), '');
159141
});
160142

161-
it('reload the commit messages from commit template', async function() {
162-
const repoPath = await cloneRepository('commit-template');
163-
const repo = await buildRepositoryWithPipeline(repoPath, {confirm, notificationManager, workspace});
164-
const templateCommitMessage = await repo.git.getCommitMessageFromTemplate();
165-
const commitStub = sinon.stub().callsFake((...args) => repo.commit(...args));
166-
const app2 = React.cloneElement(app, {repository: repo, commit: commitStub});
167-
168-
await fs.writeFile(path.join(repoPath, 'a.txt'), 'some changes', {encoding: 'utf8'});
169-
await repo.git.exec(['add', '.']);
170-
171-
const wrapper = shallow(app2, {disableLifecycleMethods: true});
172-
await wrapper.instance().commit('some message');
173-
assert.strictEqual(repo.getCommitMessage(), templateCommitMessage);
174-
});
175-
176143
it('sets the verbatim flag when committing from the mini editor', async function() {
177144
await fs.writeFile(path.join(workdirPath, 'a.txt'), 'some changes', {encoding: 'utf8'});
178145
await repository.git.exec(['add', '.']);

test/fixtures/repo-commit-template/a.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/fixtures/repo-commit-template/b.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/fixtures/repo-commit-template/c.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/fixtures/repo-commit-template/dot-git/HEAD

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)