gitClient #11
Loading…
Reference in New Issue
No description provided.
Delete Branch "gitClient"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Created git client with clone, commit, push, and delete capabilities
@ -0,0 +3,4 @@
import {cloneRepo, commitRepo, pushRepo, removeRepo} from './gitClient'
//Sample usage
cloneRepo('https://git.csclub.uwaterloo.ca/www/library.git', (temporaryDir) => {
try to build an API that returns promises. that will give you a much better design. reach out on discord if you need ideas! :)
Nice work on this!
As Adi mentioned, using promises is much prefered, since it can help us avoid http://callbackhell.com/.
I was typing out some comments to guide you, but I realized that it was a bit tricky, and one thing lead to the next and I ended up just converting the
cloneRepo
to promises (sorry, didnt mean to take away your fun!). But I still left the other functions for you to conver to promises, hopfully my code helps.Also, instead of the
useGitclientFile
, usually for things like this we use tests, so I added a test file, and wrote some tests for the clone. You can run then and inspect the output by runningnpm test
(you might have to donpm install
at first)Please add some simple tests for the other functions as well as your builing to help you develop. You don't have to do extensive tests for the tricky things (overall I decided for this projects a lot of tests are probalby not worth it), but mainly to help you develop. You can write the test and manulayy verify that the correct git action happend (commited, added, etc.) instead of having to do the "useGitClient". (Of course, if you are feeling ambitous, feel free to try doing more complicated automated tests, but its not required)
@ -0,0 +1,3 @@
{
"editor.formatOnSave": true
I enabled this so hopefully so it formats on save for everyone.
@ -0,0 +54,4 @@
});
}
function createAndPublishNewBranch(repoPath) {
If I remember correctly, I think yoy were callning this after clone? I don't think this is need to be called inside the clone method, it can be called afterwords seperatly...
gitClientto WIP: gitClient@ -0,0 +88,4 @@
try{
execSync(`rm -r ${repoPath}`);
} catch (error){
`Failed to push to repo: ${error.status}
I think you forgot a console.error here
WIP: gitClientto gitClient@ -0,0 +18,4 @@
execSync(`cd ${folderPath} && touch newFile.ts`);
await commitRepo(folderPath);
const directoryContents = readdirSync(folderPath);
expect(directoryContents).toContain("newFile.ts")
nit: (not importnat) but just wanted to point out this test doesn't actully test that it was commited. Maybe if it ran a
git add --all && git reset --hard
after the commit, it would test that the commit actually worked.Nice, great work with this!
I just adjusted that push test to expect the "unauthorized" error so it doesn't fail
when other people run it. I think the way it is right now it still kinda does test that it got to pushing, without actually having to setup correct premissions.