fix: push only tags to remote repo

This commit is contained in:
Pierre Vanduynslager 2018-11-21 12:13:36 -05:00
parent aa022e0ac2
commit 2b082acc73
2 changed files with 16 additions and 2 deletions

View File

@ -149,7 +149,7 @@ async function tag(tagName, execaOpts) {
* @throws {Error} if the push failed. * @throws {Error} if the push failed.
*/ */
async function push(repositoryUrl, branch, execaOpts) { async function push(repositoryUrl, branch, execaOpts) {
await execa('git', ['push', '--tags', repositoryUrl, `HEAD:${branch}`], execaOpts); await execa('git', ['push', '--tags', repositoryUrl], execaOpts);
} }
/** /**

View File

@ -151,7 +151,7 @@ test('Add tag on head commit', async t => {
await t.is(await gitCommitTag(commits[0].hash, {cwd}), 'tag_name'); await t.is(await gitCommitTag(commits[0].hash, {cwd}), 'tag_name');
}); });
test('Push tag and commit to remote repository', async t => { test('Push tag to remote repository', async t => {
// Create a git repository with a remote, set the current working directory at the root of the repo // Create a git repository with a remote, set the current working directory at the root of the repo
const {cwd, repositoryUrl} = await gitRepo(true); const {cwd, repositoryUrl} = await gitRepo(true);
const commits = await gitCommits(['Test commit'], {cwd}); const commits = await gitCommits(['Test commit'], {cwd});
@ -162,6 +162,20 @@ test('Push tag and commit to remote repository', async t => {
t.is(await gitRemoteTagHead(repositoryUrl, 'tag_name', {cwd}), commits[0].hash); t.is(await gitRemoteTagHead(repositoryUrl, 'tag_name', {cwd}), commits[0].hash);
}); });
test('Push tag to remote repository with remote branch ahaed', async t => {
const {cwd, repositoryUrl} = await gitRepo(true);
const commits = await gitCommits(['First'], {cwd});
await gitPush(repositoryUrl, 'master', {cwd});
const tmpRepo = await gitShallowClone(repositoryUrl);
await gitCommits(['Second'], {cwd: tmpRepo});
await gitPush('origin', 'master', {cwd: tmpRepo});
await tag('tag_name', {cwd});
await push(repositoryUrl, 'master', {cwd});
t.is(await gitRemoteTagHead(repositoryUrl, 'tag_name', {cwd}), commits[0].hash);
});
test('Return "true" if in a Git repository', async t => { test('Return "true" if in a Git repository', async t => {
// Create a git repository with a remote, set the current working directory at the root of the repo // Create a git repository with a remote, set the current working directory at the root of the repo
const {cwd} = await gitRepo(true); const {cwd} = await gitRepo(true);