KeyError in pygit upon deploying on divio.com - divio

Upon hitting the 'deploy' button on divio.com:
...
content = self[entry.id].read_raw() File
"/virtualenv/lib/python3.6/site-packages/pygit2/repository.py", line
131, in getitem raise KeyError(key) KeyError:
354abadc2fab7b4d6c752f2660577d2ac3b5f247

Thanks to the divio support I was able to resolve this problem:
divio.com does not support "empty" folders in the repository.
Check if you have any unused folders that have been created by default and delete them (if you dont use them). Since I moved all the backend functionality into a /backend folder, I opted to just delete the automatically created folders:
mario#x1a2p32:~/Projects/lwl-djangocms-blog1$ git commit -m "delete empty folders"
[master e1144fa] delete empty folders
3 files changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 private/.empty
delete mode 100644 static/.empty
delete mode 100644 templates/.empty
This solved the problem and deployments now run fine.

Related

Git creates an extra file with my machine name appended at the end

I've just altered a file and successfully committed it and pushed it and everything is fine from that point of view but when I go back into the master branch it seems to have created an extra yaml file...exactly the same as the one I've just pushed but this time it has my machine name appended to the end of it...
It started off looking like this .gitlab-ci-yml....but it's now created an extra one called .gitlab-ci-mikeslaptop.yaml in the same folder ...and posh git says [master = +1 ~0 -0 !] and git says untracked files (use "git add ,file>..." to include in what will be committed) .gitlab-ci-mikeslaptop.yaml
Has anyone ever seen this behaviour before..I'm goggling but finding nothing.
any help gratefully received

Cannot git pull due CONFLICT(MODIFY/DELETE) and symlink

Our Laravel project is using symlinks. Recently when I tried to pull from my colleague's work, I get this message:
CONFLICT (modify/delete): resources/lang/en/validation.php deleted in HEAD and modified in a262067feb430a072c1d3abf2ec500150212ff0f. Version a262067feb430a072c1d3abf2ec500150212ff0f of resources/lang/en/validation.php left in tree.
error: failed to symlink 'resources/lang/en/validation.php': File name too long
Upon trying to git rm the file, I am told it doesn't exist and is deleted in HEAD. Then when I pull I get the same message as above. Upon trying to touch the file and git add the file, and commit and then pull (in order to push my changes to the same branch), I get a similar error message:
CONFLICT (content): Merge conflict in resources/lang/en/validation.php
CONFLICT (modify/delete): resources/lang/en/auth.php deleted in HEAD and modified in a262067feb430a072c1d3abf2ec500150212ff0f. Version a262067feb430a072c1d3abf2ec500150212ff0f of resources/lang/en/auth.php left in tree.
error: failed to symlink 'resources/lang/en/auth.php': File name too long
I have tried to skip-worktree the file, assume-unchanged the file and to change the git config setting via git config --local core.longpaths true to allow long-paths. None have worked. I think it has to do with the symlink, but I haven't run the script yet and so I don't know how this is a barrier to pulling for git.
When I do try to run the symlink, I get this error message:
error: unable to create symlink resources/lang/en/auth.php: File name too long
error: unable to create symlink resources/lang/en/validation.php: File name too long
Long story short, I cannot git pull, and therefore cannot git push. What's the solution? I don't want to git push force it.
Running git pull is just running two Git commands:
First, git pull runs git fetch. This obtains any new commits needed for the second command.
Second, git pull runs ... well, this can be complicated. You are having it run the default, though: git merge.
Usually when git pull fails, one of these two commands that it runs is the one that actually failed. The second command fails more often unless you have a particularly flaky Internet connection. In your case, it's the git merge that failed.
The word failed is usually too strong, really. Most merges do not actually fail. They just stop in the middle of the operation due to a conflict (or two conflicts, in your particular case). But your merge is a little special. It really does have an internal failure, which repeats several times:
error: unable to create symlink resources/lang/en/auth.php: File name too long
error: unable to create symlink resources/lang/en/validation.php: File name too long
This is happening because your OS is placing a hard limit on the length of the target of a symbolic link. As you found:
It seems it was trying to make a symlink out of the content inside the file instead of the file name ...
Git's internal limits are much bigger than your OS's.
A symbolic link is just data, at one level, and that's how Git tends to store it (as a blob object, but one with mode 120000 rather than the normal file mode of 100644 or 100755). At another level, the data will be interpreted as a file name, and that file name tends to have a length limit, such as 1024 or 4096 bytes.
What would git show do?
git show will spill out the contents of the symlink, when pointed to a symbolic-link object.
$ git hash-object -w -t blob /usr/share/misc/termcap
d305cd8e161ecc8a78b0485d1926b9600efc6cb7
$ git update-index --add --cacheinfo 120000,d305cd8e161ecc8a78b0485d1926b9600efc6cb7,crazy
$ git commit -m "add crazy-long symlink"
[master dbb6e35] add crazy-long symlink
1 file changed, 4725 insertions(+)
create mode 120000 crazy
The normal tools will no longer work with this repository (which I made just to hold this crazy-long symlink):
$ git log | sed 's/#/ /'
commit dbb6e35967041fa4b03812866999ea0acd640dce
Author: Chris Torek <chris.torek gmail.com>
Date: Sun Nov 15 19:52:05 2020 -0800
add crazy-long symlink
commit c6e238c122dcd41410e7fdcfaa47ac112e935a35
Author: Chris Torek <chris.torek gmail.com>
Date: Sun Nov 15 19:51:58 2020 -0800
initial commit
$ git checkout HEAD^
This works fine, but trying to check out the second commit fails:
$ git checkout master
error: unable to create symlink crazy: File name too long
D crazy
Previous HEAD position was c6e238c initial commit
Switched to branch 'master'
What happens at this point is that Git simply leaves the symbolic link out of the working tree entirely. That's why it is in state D. You can still do work with the repository, but you cannot use the regular tools in the regular way.
With your merge, what you can do is delete the bad symbolic links entirely (safely), create correct (good) ones, and add them.

How to deploy an heroku application and ignore a file?

I am building a web application for an online "build your own" card game. In the application, I have a cards.json file that holds custom card data. This file is changed with fs whenever a user creates a card. Whenever I push local changes, the cards.json file gets overwritten on deploy. That means all the remote data gets lost on every deploy. How can I include a cards.json file remotely but not change the file whenever I push changes using git push heroku master?EDIT: I guess for clarification reasons, I have tried using a .gitignore as well as removing the file from the staging area. I'm not entirely sure, but I think the issue is that when the application is deployed the file is overwritten there.
So I just found out that the data created during runtime will always be deleted/reset.
https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem
I guess the best fixes for anyone else who has this same issue are:
a) Look into Databases and Heroku Add-ons, or
b) This is very workaround, and there might be better ways to do it, but:
// Go into a new directory, and use
$ heroku ps:copy <FILENAME> --app <APPNAME>
// Then, copy+paste the data from this file into your main repo.
/* Now, each time you do this, you need to make sure you delete that file from the
* extra directory you created as ps:copy only works when the file doesnt exist locally.
*/
I think git fetch doesn't work in this instance, as it only pulls that unchanged file, rather than the changed one from the dyno.
Look up the .gitignore file in git, seems to me that's exactly what you're looking for.
If it doesn't recognize .gitignore properly at first:
git add [uncommitted changes you want to keep] && git commit
git rm -r --cached .
git add .
git commit -m "fixed untracked files"
In .gitignore add the cards.json along with the path .
eg. src/test/resources/testdata/cards.json

Committed folders pushed to heroku don't make it

I'm having a weird issue when pushing my app to heroku.
It's an angularjs front app with a basic nodejs server to be able to run it on heroku.
I'm pushing a deployment branch with all the app already "compile" by grunt in a /dist folder
My problem is in the /dist/public directory, I have 4 folders : js, css, img and fonts ; but after a push and checking on the dyno with heroku run bash, only the img one is in /dist/public, the 3 others aren't there.
I try to do a new push, renaming the public folder to another name (ie shared) and this time, all 4 folders are there, so it seems heroku's doing something with folders named public but I can't figure why and how to avoid this suppression/ignoring thing.
Has any of you encountered the same issue, and how to resolve it without having to rename my public folder ?
EDIT :
Adding my .gitignore file for those of you wondering about that:
/.vagrant/machines
/node_modules
/app/bower_components
/.sass-cache
/test
/app/src/lib/config.js
/dist
Do a git add -f dist/public/js dist/public/css dist/public/fonts from within your repo.
You have a .gitignore rule for /dist, which will ignore any files within /dist and its subdirectories, unless they are already being tracked. My guess is, that the files you have newly generated were not being tracked earlier, and hence they were silently ignored.
The -f flag in the git add above will add those forcefully (overriding the ignore rule), and so you will be able to make commits.
If there are only a few files, and you want to avoid adding the whole folders, I would suggest adding each of the individual files forcefully (i.e., with the -f flag).

"nothing to commit (working directory clean)" when a folder has been added

I have a problem in git. I don't know why it says "nothing to commit (working directory clean)."
My development env: CentOS 6.4
My process is below:
mkdir develop
cd develop
git init(set user.name, user.email)
git remote add origin "repository_name"
git clone "repository_name"
Add "Test" folder
(amon2-setup.pl --flavor=Basic Test)
git status -> at this point, i can see "Untracked files ~~ Test/"
cd "Test" folder
git status -> at this point, nothing to commit (working directory clean)
Why does it say this? And if i pushed "Test", my github pushed data has been "subproject," so, i can't see Test folder's contents. Why is that?
Linux(bad)
http://www.fastpic.jp/viewer.php?file=6541584337.png
add amon files from Linux(bad i can't open files)
http://www.fastpic.jp/viewer.php?file=4456741517.png
Windows(ok)
http://www.fastpic.jp/images.php?file=8061488422.png
add amon files from Windows(ok)
http://www.fastpic.jp/viewer.php?file=8164112210.png
The gray folder for Test means:
Test is added as a submodule, which is why git status in the parent repo reports that "Test" must be added (it is a special entry in the index of the parent repo, which record that submodule)
Once in Test (which is a nested git repo), since that repo has no file, the git status reports a clear index.
Note also that Windows isn't case sensitive, so 'Test' wouldn't register properly, if there is already a 'test' (lowercase)

Resources