mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
fix(core): Support branches containing slashes in source control (#10109)
This commit is contained in:
parent
b267eb0467
commit
03a833db51
|
@ -0,0 +1,35 @@
|
|||
import { mock } from 'jest-mock-extended';
|
||||
import { SourceControlGitService } from '../sourceControlGit.service.ee';
|
||||
import { simpleGit } from 'simple-git';
|
||||
|
||||
const MOCK_BRANCHES = {
|
||||
all: ['origin/master', 'origin/feature/branch'],
|
||||
branches: {
|
||||
'origin/master': {},
|
||||
'origin/feature/branch': {},
|
||||
},
|
||||
current: 'master',
|
||||
};
|
||||
|
||||
jest.mock('simple-git', () => {
|
||||
return {
|
||||
simpleGit: jest.fn().mockImplementation(() => ({
|
||||
branch: jest.fn().mockResolvedValue(MOCK_BRANCHES),
|
||||
})),
|
||||
};
|
||||
});
|
||||
|
||||
describe('SourceControlGitService', () => {
|
||||
const sourceControlGitService = new SourceControlGitService(mock(), mock(), mock());
|
||||
|
||||
beforeAll(() => {
|
||||
sourceControlGitService.git = simpleGit();
|
||||
});
|
||||
|
||||
describe('getBranches', () => {
|
||||
it('should support branch names containing slashes', async () => {
|
||||
const branches = await sourceControlGitService.getBranches();
|
||||
expect(branches.branches).toEqual(['master', 'feature/branch']);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -244,7 +244,7 @@ export class SourceControlGitService {
|
|||
// Get remote branches
|
||||
const { branches } = await this.git.branch(['-r']);
|
||||
const remoteBranches = Object.keys(branches)
|
||||
.map((name) => name.split('/')[1])
|
||||
.map((name) => name.split('/').slice(1).join('/'))
|
||||
.filter((name) => name !== 'HEAD');
|
||||
|
||||
const { current } = await this.git.branch();
|
||||
|
|
Loading…
Reference in a new issue