Skip to content

Commit

Permalink
fix(builds): correctly parse branch names with / included (closes #429)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkuri committed Oct 27, 2018
1 parent 932a83b commit e853c96
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/api/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ function checkBranches(branch: string, branches: { test: string[], ignore: strin
function spawnGit(args: string[]): Promise<void> {
return new Promise((resolve, reject) => {
let git = spawn('git', args, { detached: true });
let err = '';

git.stdout.on('data', data => {
data = data.toString();
Expand All @@ -585,11 +586,13 @@ function spawnGit(args: string[]): Promise<void> {
}
});

git.stderr.on('data', data => err += data.toString());

git.on('close', code => {
if (code === 0) {
resolve();
} else {
reject(code);
reject(code + ': ' + err);
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/api/process-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ export function startBuild(data: any, buildConfig?: any): Promise<any> {
} else {
sha = data.data.after || data.data.sha;
if (data.data && data.data.ref) {
branch = data.data.ref.split('/').pop();
branch = data.data.ref.replace('refs/heads/', '');
}
}
} else if (isBitbucket) {
Expand Down
2 changes: 1 addition & 1 deletion src/api/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function startBuildProcess(
let restoreCache: Observable<any> = empty();
let saveCache: Observable<any> = empty();
if (proc.repo_name && proc.branch && proc.cache) {
let cacheFile = `cache_${proc.repo_name.replace('/', '-')}_${proc.branch}.tgz`;
let cacheFile = `cache_${proc.repo_name.replace('/', '-')}_${proc.branch.replace('/', '-')}.tgz`;
let cacheHostPath = getFilePath(`cache/${cacheFile}`);
let cacheContainerPath = `/home/abstruse/${cacheFile}`;
let copyRestoreCmd = [
Expand Down
1 change: 0 additions & 1 deletion src/api/webhooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
synchronizeGogsPullRequest
} from './db/repository';
import { startBuild } from './process-manager';
import { writeJsonFile } from './fs';

export let webhooks = express.Router();

Expand Down

0 comments on commit e853c96

Please sign in to comment.