How to search multiple Projects in GitLab - search

I am trying to find a way to search multiple project's code in gitlab CE.
Has anyone encountered this before, or have a recommended approach?
(I realize that if this is even possible, then I would likely need to create a script that mimics the current call from the GUI multiple times and combine the results. )

Recently came into a similar need. My particular use case is a self-hosted instance of GitLab CE. Seems like it's possible to use GitLab's API where the scope is limited to snippet, then loop through your groups and projects.
Example code:
https:// (instance_server) /search?utf8=%E2%9C%93&snippets=&scope=&search= (key words) &group_id=22&project_id=81
Other links:
GitLab's paid version.
https://docs.gitlab.com/ee/user/search/advanced_search_syntax.html#syntax-search-filters
Mention of original request (closed)
https://gitlab.com/gitlab-org/gitlab-ce/issues/14597
https://forum.gitlab.com/t/search-code-across-all-projects/2263 (SourceGraph)

You can create a Group, migrate or move all of the projects you want to search to that group, and then search just that group.

Related

How to clone all public repositories from gitlab server?

There is an unstable gitlab server and I am not sure that it will be able to work in the future. Therefore, I want to make a backup copy of all the repositories (projects) that are there.
Cloning the source code will be enough, but it will be great if there is a way to save issues as well. Are there any ways to do this?
It depends on what kind of access you have, but if you don't have administrator access to do a full backup, then the best thing to do is to use a couple of API endpoints to get the information you need and go from there.
Use the Projects API to get a list of all projects accessible to you.
Note the pagination limits.
What you store depends on how you want to get the information.
Store at least the ID number of each.
Filter by membership if you only want the ones you're a member of.
Filter by min_access_level = maintainer (or higher) if you want to export whole projects.
Use the Project export API to trigger a project export for each project you're a member of, and you're a maintainer (or higher).
For all other projects where you have a lower role, or where it's public, you could still use git clone for the repositories by storing the ssh_url_to_repo or http_url_to_repo from the Projects API and running through each.
For all other parts of a project, you could store the JSON version to recreate them later if you want to go through the hassle. For example, for issues, use the Issues API.

GitLab - Can I enable search by code or commits across all projects of GitLab?

When I select all projects, I cannot search by commits or code.
Can I enable search by code or commits across all projects?
You can only do this across an entire instance for self-managed GitLab instances OR searching across repositories within a single organization/group in GitLab.com
For example, you can search across all of the gitlab-org group or any other group/namespace you have access to.
Currently, GitLab has not enabled global code search on gitlab.com. However, self-hosted GitLab Premium and Ultimate customers can leverage the advanced search feature and enable global code search for a self-managed instance with Elasticsearch.
That might be because a true global code search does not seem to be implemented yet, as illustrated by issue 556 or issue 14597.
Which is why there are alternatives like phillipj/gitlab-search (but only to search for contents across all your GitLab repositories)

Bulk editor for Github repos?

I have a large number of private repositories in a Github org which I want to transfer to another org for archiving, and remove all teams in the process.
I already came across https://github.com/ahmadnassri/github-bulk-transfer, and I could of course also roll my own implementation with the libraries from https://developer.github.com/v3/libraries/, but I'm honestly surprised that there is no sort of bulk editor for Github repos where you can execute API commands for a selected subset of repos.
Any hints welcome!
So I did end up rolling my own, was pretty straightforward thanks to PyGTK, requests + json.
Result is up on Github: https://github.com/floe/github-bulk-editor, feedback welcome!
(Even though it only allows bulk transfer of repos, because that's what I needed right now, I've tried to keep the internals as generic as possible, so most other Github API commands should be very easy to add.)

Gitlab change default branch for every project

I am currently using GitLab Community Edition 9.0.0 and want to change default branch to "develop" for every project.
I know it can be done by project settings page but since we have almost 200 projects, is there easy way to do it?
You could use the Gitlab API to:
Get a list of all the projects (see here)
Loop on that list and edit every project to set the default_branch parameter (see here)
Here's more documentation on how to use the API.
You fist need to get a user's private token. Go to http://<gitlab_domain>/profile/account to get/generate one for your currently logged in user. You may want to do that as the gitlab administrator in order to have access to and be able to modify all those projects.
Then you need to generate the proper requests (see links above and this).

push local gitlab site issues and comments to remote repo

I've been using git for a little while now in a new project I am working on.
I decided to use GitLab.com as I would like the opportunity to keep me repos private until I'm ready to share them (which github doesn't allow me to do).
The whole beauty of git for me is that I have a copy of the whole repo on my local machine and on the remote site.
However I make lots of comments, on my 'local' gitlab instance.
I know that I can put the wiki into source control, is it possibly to do the same thing with the comments and milestones (or in some other way share them between repositories)
I feel that this should be possible.
Maybe using an rss feed to push and pull the data to / from the various locations.
Or can I use the issues as a 'mailing list' somehow, with a 'mail into list' (however I would then need to get my local gitlab instance to mail any new issues to the remote - could probably be setup using some form of 'auto forward' filter in my mail client / gmail.
Are any of these ideas even possible ?
Is there a better solution - I'd prefer something that will integrate into my gitlab instance (local and remote), rather than needing having to use a separate interface ~ I like everything to be in a single place if possible.
Remember also I like to have access to my issues etc when offline (and then have them 'sync' when I go back online).
Thanks for any help in advance.
David
You could build a script and make use of the API to sync your issues and notes. Maybe a script that pulls all of the new issues and notes and POSTs them to the equivalent projects on GitLab.com. You could run the script manually or create a cron job to post the new items periodically.

Resources