|
1 | 1 | import test from 'ava';
|
2 | 2 | import {stub} from 'sinon';
|
3 | 3 | import getLastRelease from '../lib/get-last-release';
|
4 |
| -import {gitRepo, gitCommit, gitTagVersion, gitShallowClone} from './helpers/git-utils'; |
| 4 | +import {gitRepo, gitCommit, gitTagVersion, gitShallowClone, gitCheckout} from './helpers/git-utils'; |
5 | 5 |
|
6 | 6 | // Save the current working diretory
|
7 | 7 | const cwd = process.cwd();
|
@@ -34,6 +34,28 @@ test.serial('Get the highest valid tag', async t => {
|
34 | 34 | t.deepEqual(t.context.log.args[0], ['Found git tag version %s', 'v2.0.0']);
|
35 | 35 | });
|
36 | 36 |
|
| 37 | +test.serial('Get the highest tag in the history of the current branch', async t => { |
| 38 | + // Create a git repository, set the current working directory at the root of the repo |
| 39 | + await gitRepo(); |
| 40 | + // Add commit to the master branch |
| 41 | + await gitCommit('First'); |
| 42 | + // Create the tag corresponding to version 1.0.0 |
| 43 | + // Create the new branch 'other-branch' from master |
| 44 | + await gitCheckout('other-branch'); |
| 45 | + // Add commit to the 'other-branch' branch |
| 46 | + await gitCommit('Second'); |
| 47 | + // Create the tag corresponding to version 3.0.0 |
| 48 | + await gitTagVersion('v3.0.0'); |
| 49 | + // Checkout master |
| 50 | + await gitCheckout('master', false); |
| 51 | + // Add another commit to the master branch |
| 52 | + await gitCommit('Third'); |
| 53 | + // Create the tag corresponding to version 2.0.0 |
| 54 | + await gitTagVersion('v2.0.0'); |
| 55 | + |
| 56 | + t.deepEqual(await getLastRelease(t.context.logger), {gitHead: 'v2.0.0', version: '2.0.0'}); |
| 57 | +}); |
| 58 | + |
37 | 59 | test.serial('Return "undefined" if no valid tag is found', async t => {
|
38 | 60 | // Create a git repository, set the current working directory at the root of the repo
|
39 | 61 | await gitRepo();
|
|
0 commit comments