Change "View merge request for $branch" post push message in Gitlab - gitlab

Using a self hosted gitlab instance, how can I modify this message that I get after pushing to the repository, on my git client side ?
git push
[...]
remote:
remote: View merge request for MYBRANCH:
remote: https://GITLAB_MR.URL
remote:
I tried checking the server side hooks of my omnibus installation in
/var/opt/gitlab/git-data/repositories/#hashed/MY_REPO_HASH
But I cant find any hook with this message there using grep -Hrn "View merge request"
Is this message not from a git hook ? How to configure it ?
If I cannot change it without modifying Gitlab's code, how can I add text there for pushers to read ?

As pointed out, this can only be done by modifying Gitlab's code and not by user configuration as of today.
I found the source of the message here : https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/internal_post_receive/response.rb
Of course most users wouldn't find this solution pratical.

Related

Push gitlab repository code to Google source repository

I followed below article to push gitlab repository code to Google cloud source repository but I'm getting an error on this command
git push -f google master
error: src refspec master does not match any.
error: failed to push some refs to 'https://source.developers.google.com/p/project/r/test/'
Article followed:
https://medium.com/#bamnet/cloud-source-repositories-gitlab-2fdcf1a8e50c
Is there anything , I'm doing wrong 😜? Any thoughts as to how I can avoid this error message?
src refspec master does not match any
The issue is the date of the article you are following: Aug. 2018.
GitLab Runner has changed since then, more precisely in May 2019.
The problem is described in this thread from May 2019:
Since we are using refspec to clone/fetch the repository, we checkout a specific commit and not checking out a specific branch.
When the script does git push master, the branch is nowhere to be found so git doesn’t know what to push.
That was because of, on GitLab side, MR 1203:
Basically, GitLab CE/EE sends refspecs parameter to GitLab Runner gitlab-org/gitlab-foss app/presenters/ci/build_runner_presenter.rb: this parameter is to used in GitLab Runners for fetching branch/tag refs from remote repository.
This change was introduced because we wanted GitLab Rails side to leverage respecs in order for issue 7380 "Combined ref pipelines (source+target branch)" though, there should not be a big difference between git clone $URL or mkdir $REPO_DIR && git remote add origin $URL && git fetch +refs/heads/branch_name:refs/remotes/origin/branch_name.
In fact, the new behavior has already run on our development project
https://gitlab.com/gitlab-org/gitlab-ce/pipelines and has no issues so far.
Issue 4097 was opened at the time
Workaround
Use HEAD when you want to push this to another remote.
deploy:
stage: deploy
script:
- git remote add heroku https://heroku:$HEROKU_API_KEY#git.heroku.com/<project>.git
- git push -f heroku HEAD:master
So don't push master. Push HEAD.
The OP Adam uses another workaround and add:
before_script:
- git checkout master

How to deploy Git LFS on Heroku?

I have completed a project on Node.js which has already pushed into GitHub, this project has a video which larger than 100MB which required Git LFS. Git LFS successfully pushed into the GitHub no issue at all.
The second phase of this project is to host in Heroku, this is where I got stuck. I tried both:
heroku buildpacks:add https://github.com/BureauxLocaux/heroku-buildpack-git-lfs.git
and
heroku buildpacks:add (name of the app given by heroku)/heroku-buildpack-git-lfs
When it's pushed using
git push heroku master --no-verify
I get the following error:
remote: -----> Git LFS app detected
remote: Env var BL_BUILDPACK_GIT_LFS_REPO is not set
remote: ! Push rejected, failed to compile Git LFS app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to intense-journey-80070.
remote:
To https://git.heroku.com/intense-journey-89070.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/intense-journey-89070.git'
How can I make this work?
You say
heroku buildpacks:add (name of the app given by heroku)/heroku-buildpack-git-lfs
but you shouldn't use your app name here. I guess you want to use this buildpack? In that case, you should literally do
heroku buildpacks:add https://github.com/BureauxLocaux/heroku-buildpack-git-lfs.git
You also have an error message saying
Env var BL_BUILDPACK_GIT_LFS_REPO is not set
There is some additional configuration required for the buildpack, as outlined in its buildpack page on Heroku, which you appear not to have done:
Set the following environment variable for your app:
BL_BUILDPACK_GIT_LFS_REPO to the clone URL of the repository from which to download Git LFS assets. This should include any username, password, or personal access token which is necessary to clone noninteractively. See here for details on the syntax. It must be something like git#github.com:BureauxLocaux/my-repo
BL_BUILDPACK_GIT_LFS_SSH_PRIVATE_KEY: your private key encoded in base64 with base64 -w 0. You can use heroku config:set --app preprod-bureauxlocaux "BL_BUILDPACK_GIT_LFS_SSH_PRIVATE_KEY=$(cat ~/.ssh/heroku_deploy_lfs | base64 -w 0)" to set it.
Private SSH keys should be protected bordering on paranoia, so make sure to use a dedicated SSH key that is only used for deployment of this repository. Give that deploy key the lowest level of permission that you can.
The files that are linked to Large File System (LFS) are not supported in Heroku.
So you need to move to settings on heroku to add configs vars as key “HEROKU_BUILDPACK_GIT_LFS_REPO” to value “https://#github.com//repository.git” token is a unique personal Access token.
You need to register for that in your GitHub > settings> Developer Settings for Heroku to access your LFS files and also link in buildpacks to install LFS “https://github.com/raxod502/heroku-buildpack-git-lfs.git”.
Lastly, hit the deploy button in the deploy section and you are done with your project and available for people accessing over the internet.
Unfortunately Heroku doesn’t support git LFS at the moment.
Heroku doesn’t support git lfs. Using this method can cause pushes to fail.
https://devcenter.heroku.com/articles/git#deploy-from-a-branch-besides-main
Basically you can simply follow the instruction in this post. What I need to say is that when you register GitHub app, the URL you need to fill in "Webhook URL" and "Homepage URL" is both the URL you created using heroku (Example format: https://<app-name>.herokuapp.com).

Merged code from repo not updating in production server after push

I have a post-receive hook in my server.
I also have a remote repo(origin) (branch:stage) where another developer pushes to.
I pull the commits and push them to production from my local computer.
I recently created a new branch(feature) from the latest head of the existing branch(stage), added some code and pushed the feature branch to remote repo. I merged the new features from feature branch to stage branch.
Then I pulled from the remote repo to local.
Now, I pushed the stage branch to production.
My post-receive file consists:
git --work-tree=/path/to/project --git-dir=/path/to/project.git checkout -
f stage
My head in the remote repo after merge is currently at ae228b9.
And, at the remote production hook's latest logs also points to ae228b9.
The problem is that the code from the merge are not seen in the production server.
Do I have to do something else to get the merged code to production?
After I pulled from origin and pushed to production, I tried changing the new files locally, committed them and push to the server. But, the changes are not reflected in the server.
Edit:
Also, I uninstalled apache php mysql and installed them again. Before the unistallation/installation, the home page was showing in server but the routes were not working(404 error) but the git hook was working. After the unistallation/installation, the git hook stopped working
Update:
I created a new hook with the same code as above. Now during the push I get:
remote: error: unable to unlink old '.gitignore' (Permission denied)
remote: error: unable to unlink old '.htaccess' (Permission denied)
remote: fatal: cannot create directory at '.idea': Permission denied
I tried the following code inside my project folder and project.git(hook) folder:
sudo chmod -R ug+w .;
unable to link
after which the push is a success but the changes are not reflecting.
I solved this by deleting the contents of the project folder and pushing again with some new changes.
I faced the same issue(Azure deployment)
There are two ways to ways to handle this -
Increase timeout setting (but deployment may stuck some times)
Push new changes (redeployment)
I prefer 2nd option.

Git:Heroku Repository or object not found:

Here is the error message from Heroku master push command
Git LFS: (0 of 5 files) 0 B / 167.50 MB
batch response: Repository or object not found: https://git.heroku.com/xxxx-brushlands-xx267.git/info/lfs/objects/batch
Check that it exists and that you have proper access to it
error: failed to push some refs to 'https://git.heroku.com/xxxx-brushlands-xx267.git'
Added a long text file to Git LFS (git for large files) and after that Heroku stopped working.
What might be the issue ?
A workaround:
git push heroku master --no-verify
This disables git-lfs pre-push hook. Metadata files are commited but binaries are not uploaded.
Then, as per upendra's answer, a buildpack can be used to download the files.
After alot of googling I found that the problem is with Heroku. If you are using Heroku, then Heroku doesn't support LFS and you have to look for alternatives.
I uploaded my long text file to dropbox and accessing it from there. Heroku should definitely look in to this issue.
I found a temporary solution to the problem of using Git LFS with Heroku. I am just putting it here just in case if people are still looking for it - https://github.com/git-lfs/git-lfs/issues/805
If that doesn't work, then try this out. This method worked for me - https://github.com/raxod502/heroku-buildpack-git-lfs

How can you reference a submodule in openshift

I've got an account with OpenShift which provides a git repository for each project you to work in. I've got one main project and two smaller projects resulting in a total of 3 git repositories.
I have just started to use the two smaller projects in the main project and seen that git can use the submodule command. I've added them both to the custom directory like so:
git submodule add ssh://...#app.rhcloud.com/~/git/app.git/
git submodule add ssh://...#api.rhcloud.com/~/git/api.git/
which has produced a directory structure like so:
node_modules
custom
app ------ full of tasty files
api ------ full of tasty files
index.js
.gitmodules
Within the .gitmodules file I have
[submodule "custom/api"]
path = custom/api
url = ssh://...#api.rhcloud.com/~/git/api.git/
[submodule "custom/app"]
path = custom/app
url = ssh://...#app.rhcloud.com/~/git/app.git/
Which is exactly what I want. It all works locally.
git add --all
git commit -m "new submodules"
git push
The issue is when I run the git push, it comes back with this error:
remote: Host key verification failed.
remote: fatal: Could not read from remote repository.
remote:
remote: Please make sure you have the correct access rights
remote: and the repository exists.
It looks like I need to add the ssh key of the main project to the two smaller projects so that I can ssh. Does anyone know how I can do this or have a better way of including submodules in OpenShift?
Thanks for the help in advance.
It looks like I need to add the ssh key of the main project to the two smaller projects so that I can ssh
At the parent (main) repo level, this shouldn't be the case: all the push does is to push the .gitmodules, and 2 gitlinks (special entries in the index) representing those 2 submodules.
It is more likely that the push doesn't find the proper .ssh/known_hosts, or the public/private ssh keys in order to push back to the app.rhcloud.com upstream repo: See "SSH connection problem with “Host key verification failed…” error" and "The authenticity of host can't be established".

Resources