Skip to content

Commit b6226cf

Browse files
author
SPRINX0\prochazka
committed
secret support
1 parent 05f93ee commit b6226cf

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

src/diflow.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ program
1515
.requiredOption('-r, --repo <string>', 'URL to control repo repo (configuration+state)')
1616
.requiredOption('-b, --branch <string>', 'Branch name to be processed')
1717
.option('--skip-push', 'skip pushing changes to remote')
18+
.option(
19+
'--secret <string>',
20+
'secret for accessing repo. URLs of git repos should be in shape https://${SECRET}@<url>'
21+
)
1822
.option('--clear', 'clear work repos before running')
1923
.action(options => {
2024
// console.log('repo:', options.repo);
@@ -23,6 +27,7 @@ program
2327
const processor = new Processor(options.repo, path.join(__dirname, 'workrepos'), options.branch, {
2428
skipPush: options.skipPush,
2529
clear: options.clear,
30+
secret: options.secret,
2631
});
2732
processor.process();
2833
console.log('Processing complete.');

src/processor.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { rimraf } from 'rimraf';
1919
export interface ProcessOptions {
2020
skipPush?: boolean;
2121
clear?: boolean;
22+
secret?: string;
2223
}
2324

2425
interface CommitToProcess {
@@ -63,7 +64,10 @@ export class Processor {
6364
await fs.mkdir(this.basePath);
6465
}
6566

66-
await cloneRepository(this.repoPaths.config, this.configRepoUrl);
67+
await cloneRepository(
68+
this.repoPaths.config,
69+
this.configRepoUrl.replace('${SECRET}', this.processOptions.secret ?? '')
70+
);
6771
await runGitCommand(this.repoPaths.config, `checkout ${this.branch}`);
6872

6973
const configPath = path.join(this.repoPaths.config, 'config.json');
@@ -86,9 +90,18 @@ export class Processor {
8690
process.exit(1);
8791
}
8892

89-
await cloneRepository(this.repoPaths.base, this.config!.repos.base);
90-
await cloneRepository(this.repoPaths.diff, this.config!.repos.diff);
91-
await cloneRepository(this.repoPaths.merged, this.config!.repos.merged);
93+
await cloneRepository(
94+
this.repoPaths.base,
95+
this.config!.repos.base.replace('${SECRET}', this.processOptions.secret ?? '')
96+
);
97+
await cloneRepository(
98+
this.repoPaths.diff,
99+
this.config!.repos.diff.replace('${SECRET}', this.processOptions.secret ?? '')
100+
);
101+
await cloneRepository(
102+
this.repoPaths.merged,
103+
this.config!.repos.merged.replace('${SECRET}', this.processOptions.secret ?? '')
104+
);
92105

93106
await runGitCommand(this.repoPaths.base, `checkout ${this.branch}`);
94107
await runGitCommand(this.repoPaths.diff, `checkout ${this.branch}`);

0 commit comments

Comments
 (0)