Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function assertGitWorktreeClean() {
let status = await git().status();
if (status.files.length > status.not_added.length) {
throw new CLIError(`\
You have modifications to your git worktree.
Please revert or commit them before running convert.`);
} else if (status.not_added.length > 0) {
console.log(`\
Warning: the following untracked files are present in your repository:
${status.not_added.join('\n')}
Proceeding anyway.
`);
}
}
export async function closure(context: IGeneratorDictionary) {
const git = simplegit(context.destinationPath());
try {
const checkIsRepo = await git.checkIsRepo();
if (checkIsRepo) {
console.log(
chalk`{grey - This project is already setup as a git repo; doing nothing more}`
);
} else {
console.log(
chalk`{grey - this project has {italic not yet} been setup as a git repository}`
);
await git.init();
console.log(
chalk`- This project has been registered as a {bold git} project`
);
message += `\n\n${differentialRevisionLine}`;
await git().commit(message, ['--amend']);
}
}
}
console.log(`Creating merge commit on ${remoteBranch}`);
let cherryPickHeadCommit = (await git().revparse(['HEAD'])).trim();
await git().checkout(remoteBranch);
let mergeMessage = `Merge decaffeinate changes into ${remoteBranch}`;
if (phabricatorAware) {
mergeMessage += `\n\n${differentialRevisionLine}`;
}
await git().mergeFromTo(cherryPickHeadCommit, 'HEAD', ['--no-ff']);
await git().commit(mergeMessage, ['--amend']);
if (phabricatorAware) {
console.log('Pulling commit message from Phabricator.');
await exec('arc amend');
}
console.log('');
console.log('Done. Please verify that the git history looks right.');
console.log('You can push your changes with a command like this:');
console.log(`git push ${remote} HEAD:${upstreamBranch}`);
console.log('If you get a conflict, you should re-run "bulk-decaffeinate land".');
}
del(localFolder).then(() => {
git()
.silent(true)
.clone(repoURL, localFolder)
.then(() => git(localFolder).checkout('heroku'))
.then(() => del([`${localFolder}/**/*`]))
.then(() => fs.copy(localDist, localFolder))
.then(() => git(localFolder).add(['--all', '.']))
.then(() => git(localFolder).commit('heroku updated'))
.then(() => git(localFolder).push('origin', 'heroku'))
.catch(err => console.error('failed: ', err));
});
} else {
del(localFolder).then(() => {
git()
.silent(false)
.clone(repoURL, localFolder)
.then(() => git(localFolder).checkout('stable'))
.then(() => del([`${localFolder}/**/*`]))
.then(() => fs.copy(localDist, localFolder))
.then(() => git(localFolder).add(['--all', '.']))
.then(() => git(localFolder).commit('stable updated'))
.then(() => git(localFolder).push('origin', 'stable'))
.catch(err => console.error('failed: ', err));
});
} else {
public async getVersions(): Promise {
const { path } = this
if (this.versions) return this.versions
if (!(await git(path).checkIsRepo()) || !await isRootDirOfRepo(path)) {
this.versions = []
return this.versions
}
const tags = await git(path).tags()
if (!tags.all.length) {
logger.warn([
'Cannot get template versions, May be caused by the following reasons:',
`1. repository is not a mili template(${path})`,
'2. template have not a valid tag to mark the version(e.g. v1.0.0)',
`3. cannot get versions by command: \`git tags ${path}\``,
].join('\n'))
}
this.versions = tags.all
.then(() => git(localFolder).add(['--all', '.']))
.then(() => git(localFolder).commit('heroku updated'))
public async existed(): Promise {
try {
const result = await git().listRemote([])
return Boolean(result && result.length)
} catch (e) {
return false
}
}
}