Git Product home page Git Product logo

starhook's Introduction

starhook

Starhook is a tool to manage and sync a set of repositories from a group of remote repositories to your localhost.

It was created to scratch my itch while working with hundreds of different repositories. starhook syncs with the latest remote, so the default branch of a repository on your localhost is always synced with the remote.

Why?

Here is a use case: Most of the time, you work on a feature branch, finish your work and then create a new branch from the default branch. However, you realize later that the default (main) branch is not in sync with the remote; hence there are conflicts, and you must fix them.

starhook aims to minimize spending time on solving conflicts and ensure all your repositories are in sync with remote. It fetches and updates repositories in parallel and is fast enough to sync hundreds of repositories. If you work for a company that uses hundreds of different repositories, starhook can make your day-to-day life easier and more manageable.

starhook also enables you to manipulate all your repositories locally. You can use tools like grep, awk, and sed or write scripts that run on the repositories.

Install

go install github.com/fatih/starhook/cmd/starhook@latest

Usage

Initialize & clone repositories

First, let us initialize starhook to sync the repositories. A set of repositories is called a reposet and you can have multiple reposets based on different queries. Let's start adding our first reposet.

Pass the GitHub token, the location to download your repositories and the query needed to fetch the repositories:

$ mkdir -p /path/to/repos
$ starhook config init --token=$GITHUB_TOKEN --dir /path/to/repos --query "user:fatih language:go" 
starhook is initialized (config name: 'wonderful-star')

Please run 'starhook sync' to download and sync your repositories.

The token is only needed once and is saved into your operating systems secure storage service (keychain, keyring, etc..). Now, let's clone the repositories with the --dry-run flag to see what is starhook planning to do:

$ starhook sync --dry-run
querying for latest repositories ...
last synced: a long while ago
updates found:
  clone  :  29
  update :   0

remove -dry-run to sync the repositories

As you see, it found 29 repositories. This command will download all repositories that belongs to user fatih and are classified as go programming language. For more information about the query parameter, checkout https://docs.github.com/en/search-github/getting-started-with-searching-on-github/about-searching-on-github.

Now, let's remove the --dry-run flag, starhook will execute the query and clone the repositories:

$ starhook sync
querying for latest repositories ...
last synced: a long while ago
updates found:
  clone  :  29
  update :   0
  ...
  ...
cloned: 29 repositories (elapsed time: 10.146454763s)

Update repositories

To update existing repositories, just run the sync subcommand. starhook only updates repositores that have new changes:

$ starhook sync
querying for latest repositories ...
last synced: 20 minutes ago
updates found:
  clone  :   0
  update :   1
  "starhook" is updated (last updated: 20 minutes ago)
updated: 1 repositories (elapsed time: 2.032119469s)

List repositories

To list all existing repositories, use the list subcommand and run the following command:

$ starhook list
  1 fatih/pool
  2 fatih/set
  3 fatih/structs
  4 fatih/color
  5 fatih/gomodifytags
  ...
local 29 repositories (last synced: 15 minutes ago)

Create a second reposet

As we said earlier, we can manage multiple reposet's. Let's create another reposet, but this time for repositories that are written in VimScript:

$ mkdir -p /path/to/viml-repos
$ starhook config init --token=$GITHUB_TOKEN --dir /path/to/viml-repos --query "user:fatih language:viml" 
starhook is initialized (config name: 'shining-moon')

Please run 'starhook config switch shining-moon && starhook sync' to download and sync your repositories.

Let's see all current reposets:

$ starhook config list
Name                     wonderful-star
Query                    user:fatih language:go
Repositories Directory   /path/to/repos

Name                     shining-moon
Query                    user:fatih language:viml
Repositories Directory   /path/to/viml-repos

Let's show the current selected reposet configuration:

$ starhook config show
Name                     wonderful-star
Query                    user:fatih language:go
Repositories Directory   /path/to/repos

To use the new reposet, we need to switch and sync the new reposet:

$ starhook config switch shining-moon
Switched to 'shining-moon'

$ starhook sync
querying for latest repositories ...
last synced: a long while ago
updates found:
  clone  :   5
  update :   0
  cloning vim-hclfmt
  cloning vim-go-tutorial
  cloning vim-nginx
  cloning vim-go
  cloning dotfiles
  "vim-go" is created
  "dotfiles" is created
  "vim-hclfmt" is created
  "vim-go-tutorial" is created
  "vim-nginx" is created
cloned: 5 repositories (elapsed time: 2.279053145s)

starhook's People

Contributors

fatih avatar

Stargazers

Steve Coffman avatar Onur Macit avatar Taylor Price avatar  avatar  avatar Mohammad D. avatar  avatar Parsia Hakimian avatar CF IT avatar  avatar Peter Hoeg Steffensen avatar Tanvir Raj avatar Martin Brylski avatar  avatar Mete ALANLI avatar  avatar Brian Marquez avatar Mehmet Akif Duba avatar Fabio Berchtold avatar Matthew Linney avatar Akif HARMANCI avatar Emil V avatar Aravind K P avatar Daniel Kertesz avatar lukas.zmoginas avatar Shubham Jain avatar Pavel Prishchepa avatar Melih Ozdemir avatar Ashwin Jayaprakash avatar david avatar Filippo Giunchedi avatar Márk Kővári avatar Shaun Newman avatar Doğaç Eldenk avatar lunax avatar Sergi Vos ☁ avatar Bruno FERNANDO avatar Mehmet Berk Akın avatar  avatar Marco Younan avatar  avatar Rogier Dikkes avatar Fatih ATES avatar Andrea Brancaleoni avatar raffaele messuti avatar Colin Mason avatar Gligor Gudjevski avatar Nicolas RUFF avatar layzhi avatar Solomon Sklash avatar Nicholas de Jong avatar Zac Sims avatar  avatar  avatar Ryan Armstrong avatar Dan Lemon avatar Rhys Arkins avatar  avatar Furkan avatar Ram avatar nakatanakatana avatar DD avatar Claudiu avatar Ahmed Ammar avatar Helton Marques avatar Thiago Zilli Sarmento avatar Engin Dumlu avatar Michael Wagner avatar Sergio Rubio avatar Manuel Vogel avatar Dipak Kumar Das avatar Marwan Hilmi avatar Yagizalp Zaimoglu avatar Jaikishan Tulswani avatar Vinh Quốc Nguyễn avatar Berkan Sasmaz avatar Dwi Siswanto avatar Yuvraj avatar Johan Siebens avatar Thien Nguyen avatar Fuminori Sakamoto avatar Kayla Firestack avatar Yılmaz Çakmakçı avatar Kent Gruber avatar Ivan Sotnikov avatar Can Özmen avatar M. Olcay Tercanlı avatar Xetera avatar Parvin Eyvazov avatar Evsyukov Denis avatar Serge Simard avatar Ersin avatar  avatar rollwagen avatar sudo pacman -Syu avatar Michael Recachinas avatar Anonymous avatar Ricardo M. Vilchis avatar Okan DAVUT avatar Mehmet Bora Ezer avatar

Watchers

 avatar layzhi avatar  avatar

Forkers

0xgoerlimainnet

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.