sorenlouv / backport

A simple CLI tool that automates the process of backporting commits on a GitHub repo
https://github.com/sqren/backport/blob/main/docs/config-file-options.md
Apache License 2.0
247 stars 60 forks source link

Backport always performs a clone #440

Closed MstrDC closed 2 years ago

MstrDC commented 2 years ago

I noticed that backport always performs a full clone. Why is this? Why after the first clone, doesnt check backport if the data already exists and if so, performs a simple pull? Is there a specific reason for this?

sorenlouv commented 2 years ago

Hi @MstrDC

If that's the case it's a bug. It should check for the presence of the repo in the backport folder (~/.backport/). If it doesn't exist it will clone the repo:

https://github.com/sqren/backport/blob/cb535301ba5f55f0c4f389d6ea977566797022f2/src/lib/setupRepo.ts#L16-L25

Questions

  1. What version of backport are you running?
  2. Can you check the logs in .backport/backport.debug.log

Thanks!

MstrDC commented 2 years ago

@sqren , Thanks for your quick reponse!

sorenlouv commented 2 years ago

Cool. You have the latest version of the backport tool. This might be a problem specific to Windows. I'm on a Mac but will try to find a Windows machine to reproduce.

MstrDC commented 2 years ago

@sqren , I can confirm that this is on Windows 10. Looking at this piece of code, I believe a path.normalize needs to be added. async function getIsRepoCloned(options: ValidConfigOptions): Promise<boolean> { const repoPath = path.normalize(getRepoPath(options)); const projectRoot = await getGitProjectRootPath(repoPath); return repoPath === projectRoot; }

Otherwise it is always false (debugger): projectRoot: "C:/Users/MstrDC/.backport/repositories/backport-org/backport-demo" repoPath: "C:\Users\MstrDC\.backport\repositories\backport-org\backport-demo"

So problem with back/forward slashes?

sorenlouv commented 2 years ago

Thank you so much for diving into this. Much appreciated. Will take a look at the PR.

MstrDC commented 2 years ago

Thank your for your quick response and action. Closing this issue now.