I have submodules at many different paths. Some submodules are in the root of our repository, most are in src/app/shared-comps, but many are scattered throughout. When I clone our project, the branches for submodules are all in detached HEAD state, and I want to set them on the branches specified in .gitmodules file. I currently do this manually like so:
cd submodule1 && git checkout master && cd .. &&
cd src/app/shared-comps &&
find . -maxdepth 1 -mindepth 1 -type d -exec sh \
-c "(echo {} && cd {} && git checkout our-fork && echo)" \;
# so on and so forth
How can I have a script that avoids hard-coding submodule1 goes on master branch, and src/app/shared-comps should all go on our-fork? In fact, if some shared-comps should not be on our-fork branch, but perhaps master, how can we have them go to whatever branch is specified in .gitmodules?
Whenever you want to set submodules to be on the branch set in .gitmodules, you can run this:
git submodule foreach 'git checkout `git config -f $toplevel/.gitmodules submodule.$sm_path.branch`'
This is best run when setting up a new project from scratch.
When you do a git pull and branch names change, you'll need to run it again. I am not sure of a git hook that could do this for you. Git doesn't have a post-pull hook where you can do these things
(I would put this in comment but need formatting - regarding a post-pull hook, I did notice husky printed this after my co-worker did a vanilla git pull inside WSL
internal/modules/cjs/loader.js:775
throw err;
Error: Cannot find module 'nice-try'
- /mnt/d/work/dev/projects/mhp-new/node_modules/husky/node_modules/cross-spawn/lib/parse.js
- /mnt/d/work/dev/projects/mhp-new/node_modules/husky/node_modules/cross-spawn/index.js
- /mnt/d/work/dev/projects/mhp-new/node_modules/husky/node_modules/execa/index.js
- /mnt/d/work/dev/projects/mhp-new/node_modules/husky/lib/runner/index.js
- /mnt/d/work/dev/projects/mhp-new/node_modules/husky/lib/runner/bin.js
- /mnt/d/work/dev/projects/mhp-new/node_modules/husky/run.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:772:15)
at Function.Module._load (internal/modules/cjs/loader.js:677:27)
at Module.require (internal/modules/cjs/loader.js:830:19)
at require (internal/modules/cjs/helpers.js:68:18)
at Object.<anonymous> (/mnt/d/work/dev/projects/mhp-new/node_modules/husky/node_modules/cross-spawn/lib/parse.js:4:17)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
at Module.load (internal/modules/cjs/loader.js:790:32)
at Function.Module._load (internal/modules/cjs/loader.js:703:12)
at Module.require (internal/modules/cjs/loader.js:830:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/mnt/d/work/dev/projects/mhp-new/node_modules/husky/node_modules/cross-spawn/lib/parse.js',
'/mnt/d/work/dev/projects/mhp-new/node_modules/husky/node_modules/cross-spawn/index.js',
'/mnt/d/work/dev/projects/mhp-new/node_modules/husky/node_modules/execa/index.js',
'/mnt/d/work/dev/projects/mhp-new/node_modules/husky/lib/runner/index.js',
'/mnt/d/work/dev/projects/mhp-new/node_modules/husky/lib/runner/bin.js',
'/mnt/d/work/dev/projects/mhp-new/node_modules/husky/run.js'
]
Related
I have the following directory structure for a project I'm working on:
application
package.json
client
package.json
server
package.json
Additionally, some of the dependencies used in the project have a similar client/server hierarchy with a base-level package.json. The reasoning here is beside the point. What I'm trying to do is find the installed version(s) of a given lib within this project wherever it may be getting pulled in. I had hoped npm ls would do this, but it appears to only inspect the base-level package.json files.
I'm considering writing a bash script or something that recursively finds all node_modules directories starting in the root directory and then using npm ls in each directory, but am also hoping to find an easier answer. Any thoughts would be appreciated.
I ended up defining an alias as follows:
alias npm-ls-lib='_npm-ls-lib(){ \find . -type d -name "$1" -exec npm --prefix {} ls . \; | grep -v \(empty\); }; _npm-ls-lib'
and now I can call it like this: npm-ls-lib lib-name
I have a server with two git repos on (affinage.git and avondalelibs.git) They contain code built using cmake and make.
I have access on my machine to the server using ssh - the keys are good.
The repo 'affinage' uses 'avondalelibs' as a submodule.
When I clone affinage natively (i.e. not using yocto) the following happens:
chrisbrown#thebeast:/tmp$ git clone ssh://server#thebeast:/home/server/serverrepo/affinage.git
Cloning into 'affinage'...
remote: Enumerating objects: 307, done.
remote: Counting objects: 100% (307/307), done.
remote: Compressing objects: 100% (296/296), done.
remote: Total 307 (delta 158), reused 0 (delta 0)
Receiving objects: 100% (307/307), 2.10 MiB | 7.04 MiB/s, done.
Resolving deltas: 100% (158/158), done.
chrisbrown#thebeast:/tmp$ cd affinage/
chrisbrown#thebeast:/tmp/affinage$ git submodule update --init --recursive
Submodule 'avondalelibs' (ssh://server#thebeast/home/server/serverrepo/avondalelibs.git) registered for path 'avondalelibs'
Cloning into '/tmp/affinage/avondalelibs'...
Submodule path 'avondalelibs': checked out '52d2adc212700056c4b3c9c672702da33073f86a'
Which is good.
When I use Yocto (dunfell) to build the same repo it fails:
Log data follows:
| DEBUG: Executing shell function do_configure
| Submodule 'avondalelibs' (ssh://server#thebeast/home/server/serverrepo/avondalelibs.git) registered for path 'avondalelibs'
| Cloning into '/home/chrisbrown/affinage/poky/build/tmp/work/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/affinage/1.0-r0/git/avondalelibs'...
| Permission denied, please try again.
| Permission denied, please try again.
| server#thebeast: Permission denied (publickey,password).
| fatal: Could not read from remote repository.
Yocto succeeds in cloning the top repo but fails in initialising the submodules. I am initialising them with a do_configure_prepend() as below:
do_configure_prepend() {
cd ${WORKDIR}/git
git submodule update --init --recursive
}
I can't understand why if both repos are from the same server with the same keys there is a 'permission denied'. Anyone know why this might happen?
I am new to gitlab-ci and I am trying to test my build phase but it keeps failing before last step. here is the section
build:
stage: build
before_script:
- git config user.name "$GITLAB_USER_NAME"
- git config user.email "$GITLAB_USER_EMAIL"
script:
- git add .
- git commit -m "[skip ci] migrations"
- git push "https://${GITLAB_USER_NAME}:${CI_GIT_TOKEN}#${CI_REPOSITORY_URL}" "HEAD:qa" -o ci.skip
dependencies:
- migrations
only:
- qa
This is the log, last few lines
Using docker image sha256:5b3b4504ff1f7b859dbc5d7fb86f4afc644be62f99b8ced636fbca64c8a6c2de for python:latest with digest python#sha256:73cc381fa0fe5e6d5dd38f1397da28c70096519d8818c2249f2bc8e1158ba015 ...
$ git config user.name "$GITLAB_USER_NAME"
$ git config user.email "$GITLAB_USER_EMAIL"
$ git add .
$ git commit -m "[skip ci] migrations"
HEAD detached at bf2a8e4
nothing to commit, working tree clean
Cleaning up file based variables
00:01
ERROR: Job failed: exit code 1
How can I find out what ERROR: Job failed: exit code 1 is? I am using shared runners
The error ERROR: Job failed: exit code 1 is coming from git not finding anything to commit. In other words, the below message is causing the error:
nothing to commit, working tree clean
Cleaning up file based variables
You can either may sure there is something to commit, or you can adjust your script as outlined in this related thread: How to git commit nothing without an error?
I’m trying to make an easy-to-use NPM package out of my nextjs-generic-landing-page and the NPM is now at https://www.npmjs.com/package/nextjs-generic-landing-page
For some reason, the components using styled-jsx do not work, they render weirdly and produce a warning:
index.js:1 Warning: Received `true` for a non-boolean attribute `jsx`.
If you want to write it to the DOM, pass a string instead: jsx="true" or jsx={value.toString()}.
in style
in div
in SocialSharing (at pages/index.js:32)
…
Here’s the code I use to build the NPM package using Babel:
"publish:npm": "rm -rf dist && for folder in {components,lib,config,public}; do mkdir -p dist/${folder} && babel ${folder} -d dist/${folder} --copy-files --presets=#babel/preset-env,next; done && cp package.json dist/"
Any tips?
I was missing the styled-jsx/babel plugin:
"publish:npm": "rm -rf dist && for folder in {components,lib,config,public}; do mkdir -p dist/${folder} && babel ${folder} -d dist/${folder} --copy-files --presets=#babel/preset-env,next --plugins=styled-jsx/babel; done && cp package.json dist/"
What is the bzr equivalent of
cd ..
rm -fr widelands
git clone url/to/widelands.git
?
After searching for hours yesterday, how to get rid of local changes, I rage quit and did:
$ cd ..
$ rm -fr widelands
$ LANG=C bzr branch lp:widelands # LANG because of the well known not yet fixed bug
Branched 8986 revisions.
$ cd widelands
$ LANG=C bzr checkout
bzr: ERROR: A control directory already exists: "file:///[...]/widelands/".
???
$ LANG=C bzr remove-tree .
bzr: ERROR: Working tree "[...]/widelands/" has uncommitted changes (See bzr status).
????????????
$ bzr status
removed:
[list of thousands of files]
?????????????????????????????????
$ ls -lA
total 2
drwxr-xr-x 6 root root 2048 Feb 21 15:43 .bzr
According to this page https://wl.widelands.org/wiki/Building%20Widelands/, the steps to get the current development version of widelands is:
bzr branch lp:widelands
cd widelands
bzr checkout
[further steps to compile etc]
And that's basicly, what I tried above.
/edit: I now successfully tried LANG=C bzr revert --no-backup which didn't help me in the old repository before I rage quit, but the question still applies.
If what you're trying to do is remove the existing clone and create a new one, then the equivalent in bzr is:
$ cd ..
$ rm -fr widelands
$ bzr branch lp:widelands widelands
If you're trying to get rid of pending changes in the current control directory (i.e. git reset --hard), then bzr revert is what you're after.