Code Monkey home page Code Monkey logo

gitlab-global-code-search's Introduction

General

Will search through all known Gitlab projects on YOUR own instrance of GitLab.

Projects permisson must be set to public for script to work

Before the first run, please replace 4 params in config.yml:

Script was tested on Gitlab community version 11.8.1

GITLAB_URL: https://your.gitlab.uri   (What is your Gitlab url, use http:// if https:// isn't configured)
PRIVATE_TOKEN: YOUR_TOKEN (Token to use to talk to gitlab. Needs to be admin token)
REMEMBER_USER_TOKEN: YOUR_COOKIE_TOKEN (Your gitlab login cookie token)
COLOUR: true (if 'false', results are printed in monochrome)

You can safely copy config.yml.example to config.yml and edit.

Usage

Note below bundle isn't needed, because the script seems to only dependt on have ruby installed.

Script was tested with:

ruby: 2.5.5p157
gem: 2.7.6.2

If errors occours with json, try installing bundle with the code below. The code might need sudo permissons for installations, check the erorrs for permisson errors. run this code within this repo, to locate the gemfile

$ gem install bundler:1.11.2

$ gem install json


$ bundle install

# if json fails, try

$ gem 'json', '>= 1.8' or $ gem install json -v '1.8.3'

Usage: ./gitlab_global_code_search [options]
    -d, --dryrun
    -r, --recache
    -s SEARCH_STRING,                [REQUIRED]
        --search-string
    -n, --namespaces NAMESPACES      [REQUIRED] Comma separated list of namespaces (you can set namespaces=all to search through all Gitlab repos, but mind the Load on the server

First time project runs it will need to create local cache, so don't wonder why it loads 100 projects per GitLab page.

Next time you need to recache use --recache option

Examples

  • Locate word 'azure' in all found project code
./gitlab_global_code_search.rb -s azure -n all
  • Locate word 'findme' in projects with namespaces namespace1 and namespace2
./gitlab_global_code_search.rb -s findme -n namespace1,namespace2
  • Locate word 'foo' in project with namespace namespace1 and print results to foo.txt
./gitlab_global_code_search.rb -s foo -n namespace1 | tee result/foo.txt

gitlab-global-code-search's People

Contributors

opt9 avatar diuw avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.