Open ad-m opened 3 years ago
Hey @ad-m, thanks for your suggestion. To be honest, I wasn't familiar with the diff-index
command. Would you be willing to explain your use case?
At my side, I run has-changed-path
after cloning the repository. This means the repo isn't in a dirty state scenario. Are you running something like a linter before the action?
I would like detect non-committed changes in local repository. To have dirty repository clone repo and change file without commiting them. Your action is about committed changes and I suggest to test for uncommitted changes.
Hi @ad-m, sorry for the wait. I understood what you meant, great suggestion! Thanks 😀
I need to write a few unit tests for this function in order to guarantee the changes are being detected. After that, I would be willing to change to git diff-index
.
My biggest fear right now is adding a breaking change, as some people are using this action in production.
Do you have any examples of testing git functionalities? My current idea is to create a bunch of test helper functions, such as: createFolder(name: string)
, createGitRepo()
, createFile(name: string)
, stageFile(name: string)
, createCommit(msg: string)
. Then, I would use those functions to create a few common examples.
My biggest fear right now is adding a breaking change, as some people are using this action in production.
At first, I thought that this should be an opt-in option - check commited / uncomitted changes.
Do you have any examples of testing git functionalities?
No, but I have experience with end-to-end API testing which requires a complex remote state to perform the operation.
In my experience, it is worth considering several elements:
createFolder(name: string)
, createGitRepo()
, createFile(name: string)
, stageFile(name: string)
, createCommit(msg: string)
seems to be effective in this regard, because the test will be easy to read,try { ...test... } finally {...cleanup...}
.Consider following snippet of code in JavaScript:
const withGit = (fn) => t => {
try{
const gitRepoPath = createGitRepo(fn);
await fn(t, gitRepoPath)
} finally {
await cleanupGit(gitRepoPath);
}
}
ava.test(withGit((t, gitRepoPath) => {
t.true(true);
}));
What do you think about adding support detecting dirty state of repository also? You need run:
instead of: