Skip to content

Commit

Permalink
refactor - single branch run
Browse files Browse the repository at this point in the history
  • Loading branch information
SPRINX0\prochazka committed Feb 21, 2025
1 parent 3c0ce80 commit c8aa98d
Show file tree
Hide file tree
Showing 9 changed files with 189 additions and 131 deletions.
24 changes: 24 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@types/lodash": "^4.17.15",
"commander": "^13.1.0",
"lodash": "^4.17.21",
"minimatch": "^10.0.1",
"rimraf": "^6.0.1"
}
Expand Down
14 changes: 7 additions & 7 deletions src/diflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Git Repository Tests', () => {

await beforeDiflow();

const processor = new Processor(getTestRepoPath('config'), path.join(__dirname, 'workrepos'));
const processor = new Processor(getTestRepoPath('config'), path.join(__dirname, 'workrepos'), 'master');
await processor.process();

await afterDiflow();
Expand All @@ -45,7 +45,7 @@ describe('Git Repository Tests', () => {

await beforeDiflow();

const processor = new Processor(getTestRepoPath('config'), path.join(__dirname, 'workrepos'));
const processor = new Processor(getTestRepoPath('config'), path.join(__dirname, 'workrepos'), 'master');
await processor.process();

await afterDiflow();
Expand All @@ -72,7 +72,7 @@ describe('Git Repository Tests', () => {

await beforeDiflow();

const processor = new Processor(getTestRepoPath('config'), path.join(__dirname, 'workrepos'));
const processor = new Processor(getTestRepoPath('config'), path.join(__dirname, 'workrepos'), 'master');
await processor.process();

await afterDiflow();
Expand Down Expand Up @@ -103,7 +103,7 @@ describe('Git Repository Tests', () => {

await beforeDiflow();

const processor = new Processor(getTestRepoPath('config'), path.join(__dirname, 'workrepos'));
const processor = new Processor(getTestRepoPath('config'), path.join(__dirname, 'workrepos'), 'master');
await processor.process();

await afterDiflow();
Expand Down Expand Up @@ -132,7 +132,7 @@ describe('Git Repository Tests', () => {

await beforeDiflow();

const processor = new Processor(getTestRepoPath('config'), path.join(__dirname, 'workrepos'));
const processor = new Processor(getTestRepoPath('config'), path.join(__dirname, 'workrepos'), 'master');
await processor.process();

await afterDiflow();
Expand All @@ -147,7 +147,7 @@ describe('Git Repository Tests', () => {
expect(content3).toBe('content3');
});

test.only('Ignore path', async () => {
test('Ignore path', async () => {
const folder = path.join(getTestRepoPath('diff'), '.github', 'workflows');
await fs.mkdir(folder, { recursive: true });
await createTestCommit(
Expand All @@ -159,7 +159,7 @@ describe('Git Repository Tests', () => {

await beforeDiflow();

const processor = new Processor(getTestRepoPath('config'), path.join(__dirname, 'workrepos'));
const processor = new Processor(getTestRepoPath('config'), path.join(__dirname, 'workrepos'), 'master');
await processor.process();

await afterDiflow();
Expand Down
40 changes: 32 additions & 8 deletions src/diflow.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,39 @@
import path from 'path';
import { Processor } from './processor';
import { Command } from 'commander';

if (process.argv.length < 3) {
console.error('Usage: gitdiff <state-repo-url>');
process.exit(1);
}
const program = new Command();

const skipPush = process.argv.includes('--skip-push');
const clear = process.argv.includes('--clear');
program
.name('diflow')
.description('Git diflow - maintain sync between GIT 3 repos (base+diff=merged)')
.version('1.0.0');

const processor = new Processor(process.argv[2], path.join(__dirname, 'workrepos'), { skipPush, clear });
processor.process();
program
.command('sync')
.description('Ryn sync between GIT 3 repos (base+diff=merged)')
.requiredOption('-r, --repo', 'URL to control repo repo (configuration+state)')
.requiredOption('-b, --branch', 'Branch name to be processed')
.option('--skip-push', 'skip pushing changes to remote')
.option('--clear', 'clear work repos before running')
.action(options => {
const processor = new Processor(options.config, options.branch, path.join(__dirname, 'workrepos'), {
skipPush: options.skipPush,
clear: options.clear,
});
processor.process();
console.log('Processing complete.');
});

// if (process.argv.length < 3) {
// console.error('Usage: gitdiff <state-repo-url>');
// process.exit(1);
// }

// const skipPush = process.argv.includes('--skip-push');
// const clear = process.argv.includes('--clear');

// const processor = new Processor(process.argv[2], path.join(__dirname, 'workrepos'), { skipPush, clear });
// processor.process();

console.log('Processing complete.');
Loading

0 comments on commit c8aa98d

Please sign in to comment.