git http backend problems push data compiler

31 views Asked by At

how to make push code compiler using git http backend

If the user pushes now, the code compiler that was pushed should return the result

TODO: get commit message and push data code compiler :_

I tried to write

import { Git } from 'node-git-server';
import { fileURLToPath } from 'url';
import { join, dirname } from 'path';
import { existsSync, mkdirSync } from 'fs';
import http from 'http';

// Use import.meta.url to get the current module's URL
const __filename = fileURLToPath(import.meta.url);
// Use dirname to get the directory name
const __dirname = dirname(__filename);

const port = 2222;

const repoPath = join(__dirname, './repo');
const startFolder = join(__dirname, './compiler');

// Check if the repo folder exists, and create it if not
if (!existsSync(repoPath)) {
  mkdirSync(repoPath);
}
const repos = new Git(repoPath, {
  autoCreate: true,
  checkout: true,
});

repos.on('push',  (push) => {

  push.log(`push ${push.repo}/${push.commit} ( ${push.branch} )`);

  // **TODO: get commit message and push data code compiler :_**
  
  push.log();
  push.accept()
});


repos.server = http.createServer((req, res) => {
  repos.handle(req, res);
});

repos.server.listen(port, "0.0.0.0", () => {
  console.log(`node-git-server running at http://localhost:${port}`);
});
0

There are 0 answers