diff --git a/lib/git.js b/lib/git.js index 77931be9..be0cdaa1 100644 --- a/lib/git.js +++ b/lib/git.js @@ -149,7 +149,7 @@ async function tag(tagName, execaOpts) { * @throws {Error} if the push failed. */ async function push(repositoryUrl, branch, execaOpts) { - await execa('git', ['push', '--tags', repositoryUrl, `HEAD:${branch}`], execaOpts); + await execa('git', ['push', '--tags', repositoryUrl], execaOpts); } /** diff --git a/test/git.test.js b/test/git.test.js index 3f80da12..82d4b0b1 100644 --- a/test/git.test.js +++ b/test/git.test.js @@ -151,7 +151,7 @@ test('Add tag on head commit', async t => { 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 const {cwd, repositoryUrl} = await gitRepo(true); 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); }); +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 => { // Create a git repository with a remote, set the current working directory at the root of the repo const {cwd} = await gitRepo(true);