Get current Github Repository name with Octokit

620 Views Asked by At

I'm trying to get some information about the current Github Repo Projects, for a VsCode Extension, But I don't know (Haven't found it in the Documentation) how to get the current Repo name. With that information, I would try to execute the following (Which I got from the documentation & works when I hard code a rep name as a string).

return await octokit.rest.projects
  .listForRepo({
    owner: userInfo.data.login,
    repo: currentRepoName,
  });
1

There are 1 best solutions below

0
On

Thanks to the help of @Gregor I got the following solution know. It's not quite pretty, so I'm still happy for any suggestions:

let file = await fs.readFileSync(require("path").resolve(__dirname, '../.git/config'), 'utf8');
let repo = (file.match('[^\/]+(\.git)')!)[0].toString().replace(".git", "");