using git checkout without using hooks - githooks

I'm working on multiple repositories and one has some commit policies forced by client side hooks.
When I work in this repo and switch to the devel branch, it takes some time for the "hook preparations".
Can I somehow switch the current branch and forcefully ignore the hook stuff?
I know the option --no-verify for commit, but it is not working on checkout.
Environment: Windows, but this should be irrelevant
I tried the following:
git.exe checkout --no-verify develop --
->
error: unknown option `no-verify'
usage: git checkout [<options>] <branch>

An alternative would be to use git worktree (detailed here) in order to have two different folders:
one for your repository develop branch
one for your repository normal working branch (a topic branch)
That way, you can switch from one branch to another without triggering any hook.
That being said, since git checkout is a local operation, check your <repo>/.git/hooks/post-checkout file, and why that script takes so much time.

Related

Turborepo with 2 react apps and CircleCI CI/CD only run for changed app

I'm using Turborepo for my monorepo project, i have 2 react apps. How can i configure Turborepo and CircleCI (repos are on Github) so if i make changes to one project that pipeline is not going to run for second project?
I know turbo is using hash algo to check if there is any changes to a project and then rebuild it.
I have tried looking here https://turborepo.org/docs/ci/circleci but does not explain the behavior of this.
Steps would be:
Make code change to Project 1
Commit changes of monorepo to Github
Github detects a commit and triggers CircleCI to run CI/CD
So this part is what I'm not sure, if it triggers CI/CD it will trigger for the both projects right? And if so how can i prevent only for the one i have made changes?
I've been working on such a solution for days now. There are two core-concepts in turborepo to achieve this:
Filtering workspaces
Caching Buildoutputs and store the cache in the cloud (not what you're looking for)
So, you can filter your monorepo for a specific project, e.g:
pnpm turbo run build --filter='my-project...[HEAD^1]' --dry=json
-> This will look if the task build is needed to run for the project "my-project", comparing the current source with "HEAD^1". The option dry=json helps to just look if there would be a need to run "build" or not for "my-project".
You could filter a whole lot more, check the docs.
Now, what i have built on top of this:
A new job on the github workflow looks with the help of this filter command if a deployment of my graphql-server is needed and he will set the output of this decision as an artifact, to provide this information for later jobs (https://github.com/actions/upload-artifact)
My actual docker-build and deploy-to-fly-io jobs that run afterwards, will download this artifact and set a CONTINUE environment variable, depending if it should build + deploy or not.
Every job coming after that is having an if: ${{ env.CONTINUE == 'true' }} to skip them if no build/deploy is needed.
It could be much simpler if you can run your build/deploy job directly with the turbo cli, because then you can just combine your filter and the execution of the build - but that was not possible in my case.
If you need to "skip" jobs that are coming later in your workflow, it's harder thant it should, as github is not supporting "abortion" of jobs.
For all the other commands like lint, typecheck and test -> just add an appropriate filter option to them and you will achieve that they only run on your "affected" workspaces/projects in your PR.
Ressources:
https://dev.to/ngconf/deploying-nx-affected-apps-from-github-actions-54n4
How can I get the previous commit before a push or merge in GitHub Action workflow?
https://github.com/orgs/community/discussions/26313

why gitlab ci-cd does not change the file?

I created a Gitlab Ci-CD to remove react and react-dom from devDependencies in package.json when i push my code to master.
but as you can see it says that pipline is passed and job is succeeded but when i look at my master branch react and react-dom are not removed from devDependencies and they are still there.
what should i do with that?
A GitLab CI job doesn't change any of your repository files. It pulls a copy of the repository so that it can run a script, test, etc. against it. If the specified job runs successfully without throwing any errors (exit code), then the job succeeds/passes. You can find a more detailed explanation in the GitLab CI/CD documentation.
If you want to make changes to the repository, you need to have the script run to make the changes, then commit the changes, and push those changes to the repository using the standard git commands.
Just remember that you'll have to authenticate using HTTPS or using SSH.
You'll also likely find this StackOverflow answer on pushing to a GitLab repository through a CI job helpful as well.

Properly setting up React app to work with other devs in VS Code

I am learning React with my son using VS Code a and we are having a hard time properly syncing and setting up how to work with the same files on Github.
We have a repo with source files. Let's call it 1st-repo. His PC is fine as he has control of the repo (master). I would like to fork this repo (I think?) so I can have all the files and make my own changes.
I'm really not sure how to start in VS Code. DO I first do a blank app "npx create-react-app {name}" then clone? Or do I set it up through git/github in VS code.
Once there is the initial setup I would love to see how people work together.
You definitely don't want to npx create-react-app {name} as this will create a new application project.
If you are simply wanting to work on the same project at the same time then you only need to clone the Github repo to your machine.
git clone <link to repo>
Then change directory into the project and install the project's dependencies. This assumes you already have node installed on your machine.
cd <project directory>
npm install
From here you can open the project up in VSCode, make your changes, and commit & push them back to the remote repo. I suggest getting familiar with Git and the pull, commit, and push commands. Also get familiar with creating and switching between working branches.
Git cheet sheet
If you and your son are working on the same code in the same branch at the same time then merge conflicts will likely arise when either of you are pushing your changes back to the remote. Get in the habit of pulling any changes from the remote before you commit and push your changes, it's easier to resolve conflicts this way. VSCode even makes this stupid simple in the GUI.
VSCode also features a VS Code Share extension, called Live Share, that allows you to work in a shared window. You can see each other's cursors and position in the code.
Good Luck.

Imported linked libraries resets back when rebuilt - how to avoid for specific libraries?

I'm trying to make modifications to some of the imported libraries that I added using yarn. When I make a change to those libraries under node_modules, and then run react-native run-android, modifications are updated then. But when I run react-native run-android the next time, it gets reset back to the original.
I wanna make changes to it and save it with my custom modifications. How do I avoid it getting reset back to the original library? This question might sound really basic and stupid, but I have no idea how to and I can't find any solution to this when I tried to search a solution for this.
node_modules must not be changed manually as it is assumed to be read-only dependency.
If you still want to change one of node_modules , you have three ways :
Create a pull-request which contains your changes to the repository of this module and follow up with the owner of repository until merge the pull-request and publish your changes in npmjs.com.
Definitely, this solution can take much time which breaks your productivity . If so , the best solution is :
Fork the repository of the module , make changes and if the license allows you , publish your repo under https://npmjs.com using
cd /path/to/your-repo-after-changes;
npm publish;
Then go back to your project and run :
yarn add your-repo-after-changes ;
According to license, you may copy/paste the module source code that you want to change to your project under a folder (external-modules for example) , make your changes and export from external-modules .

Maven update with new file with the same version

I am using Maven and have a problem - if my colleague update jar file - Maven doesn't update it. So I have go to .m2/repository and manually delete it. After this Maven update dependance jar correct.
But may be exists another way to adjust, without each time delete manually?
Thanks.
First, you should make sure that your colleague's artifact is released with a SNAPSHOT version number as long as it it is not yet stable (see http://www.sonatype.com/books/mvnref-book/reference/pom-relationships-sect-pom-syntax.html#pom-relationships-sect-snapshot-versions). This will cause Maven to check for updates regularily.
To specify how often the check occurs, you can modify the updatePolicy of the repository to which your colleague deploys (see http://maven.apache.org/settings.html#Repositories). You can set it to always to make Maven pull snapshot updates as soon as your colleague deploys them.
You can also add -U to the mvn command to force maven to check the repository for updates (mvn clean install -U) but like dosendoc said first make sure you're working off SNAPSHOT versions.

Resources