How to auto run bash commands after each git rebase --continue? - reactjs

I am trying to rebase a branch onto a drastically different one. It's a React project. If I merge two branches brutally, I cannot even compile the code. Therefore, I am trying to rebase interactively.
While doing that, I want to make sure that after each rebase step the code base can compile. What would be a way to automatically reinstall node_modules and rerun the project (say I use yarn start to run the project) after each git rebase --continue?
Or if I am not on an ideal route, what would be the right way to merge those two branches?

The way to do this is use -x/--exec to run a command between each step. For example, if I do:
git rebase HEAD~3 -i -x 'npm run ship'
Then I see the following rebase plan:
pick <hash> <message>
exec npm run ship
pick <hash> <message>
exec npm run ship
pick <hash> <message>
exec npm run ship
In this case npm run ship is the command that runs all of the linting, testing, etc. to check that each commit is still good.
Note that the command needs to succeed (i.e. exit 0) for the rebase to continue, so make sure that's true of whatever you plan to do to check each commit.

Related

Accidentally amzn-sagemaker-studiolab package & now have weird UI

I'm very new to Studiolab and I was trying to uninstall some packages I installed with pip. I was lazy and found this script online that did this for me. I ran "python -m pip freeze > requirements.txt" followed by "python -m pip uninstall -r requirements.txt". In the process, I deleted a couple important packages including amzn-sagemaker-studiolab. Could you point me in the right direction as to how I may be able to reset my environment to the default one. I am entirely okay with starting fresh, like I never worked on the environment before but my UI right now is pretty unusable and I can't figure out how to re-install the packages I deleted.
Most of the information is present in the details.
Here are the commands you can use to reinitialize Studio Lab environment:
Open Terminal from JupyterLab IDE
Make sure you are under your home directory
Run rm -rf ..?* .[!.]* * and restart your project runtime, that should reset it
If that still does not work, the only recommendation we have is to delete and recreate your account.

Git add -A usage

I am using Husky in my ReactJs project. The idea is when user will commit the changes there should be run some lint commands.For this i added in my package.json:
"lint": "next lint --fix",
"lint:fix": "lint && git add -A .",
Before committing the message i run lint:fix. Everything is working. Also i know that this command git add -A . will add the changes if they will occur after lint command, so if the dev will commit => lint will fix the issues => and if there are some changes git automatically will add these changes to the commit without doing again git add . and git commit -m .... Question: Have this command git add -A . any disadvantages and is it ok to add there?
Have this command git add -A . any disadvantages
First git add . is enough (the -A is the default since Git 2.x)
Second, the main (in general) inconvenient is that it adds everything, even if you might have other unrelated modifications. It also adds new files.
In your case (used in a pre-commit hook), you have prepared your index (git add only the files you want to commit): the git add . might risk adding other files that you did not want initially to iclude in your next commit.
another question, is lint-staged (https://npmjs.com/package/lint-staged) the same as git add -u in my situation "lint:fix": "lint && git add -u"?
The README mentions:
From v10.0.0 onwards any new modifications to originally staged files will be automatically added to the commit.
If your task previously contained a git add step, please remove this.
The automatic behaviour ensures there are less race-conditions, since trying to run multiple git operations at the same time usually results in an error.

How to disable git hooks in gitkraken?

I'm working with a project that has git hooks configured. Unfortunately. It was added to prevent juniors or headless developers to commit CI-check-failing code to their branch.
I am one of these, who ignore git hooks with HUSKY_SKIP_HOOKS env variable, but for me it doesn't work in GitKraken.
Do you know how to ignore git hooks in GitKraken?
Well, I did receive a response from their support, that works for me.
Additionally, you should still be able to disable these hooks from executing. You will need to change the chmod permissions for the files, which reside under local_repo/.git/hooks.
chmod -x .git/hooks/*
And it works for me.
Are you using the command instruction like that HUSKY_SKIP_HOOKS=1 git <command> ...?
You can use it like HUSKY_SKIP_HOOKS=1 but also HUSKY_SKIP_HOOKS=true.
You can also bypass commit hooks in command line with : git commit -m "bla bla" -n.
If you'll be unable to run hooks for a long time, you also can use the core.hooksPath git configuration option:
git -c core.hooksPath=/dev/null checkout master
git -c core.hooksPath=/dev/null pull
git -c core.hooksPath=/dev/null commit ...
git -c core.hooksPath=/dev/null push
...
And (just sayin'), SourceTree has an interface option to skip commit hooks. As far as I know Git Kraken doesn't have one.
Sadly there doesn't seem to be a simple way to do this from the GitKraken. As others have pointed out you should pass in the Husky environmental variable normally. But here's a guaranteed simple solution that will always work. I'm currently using it to clean up some old repositories.
# Temporarily wipe husky
npm uninstall husky
# Clear out the husky package changes so we don't accidentally commit them
git reset --hard HEAD
When you're done in GitKraken re-install husky as so.
npm install

NPM works on Command Line, but not in Jenkins

I am having trouble getting Jenkins to use the "npm" command from the "Execute shell" (under the "Build" step).
I am attempting to set up a new Jenkins instance (a copy from a previous one). I just imported the old jobs and am now getting the various services that these jobs depend on (e.g. maven, nodejs, ansible etc.) installed.
I am having trouble getting nodejs and npm, in particular, set up.
When I type the command "npm install" on the command line, I get the following:
uws#9.14.0 install /var/lib/jenkins/workspace . . .
. . .
Binary is fine
added 1282 packages in 36.424s
When I then attempt to run the same command using the Jenkins execute shell, I get the following:
+ npm install
/tmp/jenkins7750702649955218109.sh: line 2: npm: command not found
Build step 'Execute shell' marked build as failure
Why would this command be accessible to me from the command line but not to Jenkins?
Some things I have checked:
-The path to "node" and "npm" are both on the path. At least "shortcuts" are on the path (this worked in the previous Jenkins instance).
-The node and npm binaries have root:root ownership, but their security settings are (currently) 755 (or -rwxr-xr-x).
-I have the nodejs plugin installed. Not sure of how to use it, but its settings match those on the previous Jenkins instance. Both instances use the execute shell (as opposed to any special Jenkins tool) to run the "npm" commands, whilst only the old version worked.
So, what else should I be checking that I am not? What does Jenkins require to access the "npm" command?
Try this below options in Jenkins
Option 1:
Option 2:

Push changes to bitbucket using atom

I am using the text editor Atom and it should be possible to upload directly to bitbucket from atom. I found a thread here on stackoverflow someone asked for this and someone recommended git-plus package. I did download this package but it tells me i need to edit user.email and user.name variable in gitconfig file. But it doesnt say anywhere where i can find this gitconfig file. I found a few config files but none of them have these variables. Is this gitconfig file in my .git folder in my project or is it somewhere in atom? I hope someone here can help me with this
Set up git in your shell to use bitbucket as the remote repo.
You will first need to sort that basic Git config thing about the emails:
$ git config --global --get user.name
Your Name Here
$ git config --global --get user.email
your_email#someplace.com
If you don't have these values already added, then simply add them. Put your current directory someplace under the root of your atom repository (or, if you want to use the --global parameters [recommended]), then anywhere will do, really so long as it's your login you're working with.)
$ git config [--global] user.name "Your Name"
$ git config [--global] user.email "your_email#somplace.com"
First set up your ssh key so you don't have to type your password on every command. Once that's done, then go to the Git repo you set up for your Atom project. Most likely that's in the top level of my project. Go there and...
$ git remote -v
$ git remote add origin git#bitbucket.org:youruid/yourrepo.git
Now try it from the shell to make sure all is working:
$ git push
It's very likely you'll get a message similar to:
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
Follow the advice given, then, if you're feeling particularly paranoid, make a change to any file in the repo -- using atom if you like, doesn't matter -- and try it all again:
$ git add -u
$ git commit [-v]
...
$ git push
This time, it should go off without a hitch.
Now back to atom...
If you've configured things there so that atom can access your Git repo locally, there should now be a Fetch widget in the lower right corner:
If you make a change now in atom, you'll see this change to Push... with the functionality to match.
The GitHub widget still doesn't do anything -- which is mildly annoying -- but I believe you might be able to find an atom package out there that does similar things.

Resources