Giter Site home page Giter Site logo

gh-submodule-add's Introduction

Synopsis

With option -C clones a set of repos from a specified organization. If -C is omitted and the command is executed inside a repo, the cloned repos will be added as submodules to the current repo.

Installation

gh extension install crguezl/gh-submodule-add

Requirements

Node.js has to be installed. To have fzf installed is convenient but not essential.

Usage

Usage: gh submodule-add [options] [organization] -- [git submodule options]

Options:
  -V, --version                              output the version number
  -s, --search <query>                       search <query> using GitHub Search API
  -r, --regexp <regexp>                      filter <query> results using <regexp>
  -c, --csr <comma separated list of repos>  the list of repos is specified as a comma separated list
  -f, --file <file>                          file with the list of repos, one per line
  -n --dryrun                                just show what repos will be added as submodules
  -C --clone                                 clone only. Skip submodule adds and aborbgitdirs steps
  -o --org <org>                             organization or user
     --default                               Implies "-o <org>". Set "org" as default organization for future uses
  -D --depth <depth>                         Create a shallow clone with a history truncated to <depth> number of commits
  -d, --debug                                output extra debugging
  -p --parallel <int>                        number of concurrent  processes during the cloning stage (default: 2)
  -h, --help                                 display help for command
  • If the organization is not explicitly specified, the selection will be done interactively among the list of your organizations
  • You can set the default organization through the "--default" option for future uses of this program
  • If no repos are specified the selection of repos will be done interactively among the repos in the org
  • Option '-s' assumes all the repos belong to the same org
  • When called with option '-s .', the dot '.' refers to all the repos. fzf will be open to select the repos
  • The current folder must be the root of a git repo unless options '-n' or '-C' are used
  • When in fzf, use CTRL-A to select all, tab to select/deselect

Examples

The following example clones all the repos from org ULL-MFP-AET-2122 that are in the GitHub Classroom Assignment latex-markdown and match the regular expression /marrero|maury|coell/

 gh submodule-add -C -o ULL-MFP-AET-2122 -s latex-markdown -r 'marrero|maury|coell'
cloning with 2 concurrent processes ...
[0] Clonando en 'latex-markdown-alejandro-marrero-diaz-alu100825008'...
[1] Clonando en 'latex-markdown-adela-gonzalez-maury-alu0101116204'...
[0] git clone https://github.com/ULL-MFP-AET-2122/latex-markdown-alejandro-marrero-diaz-alu100825008.git exited with code 0
[2] Clonando en 'latex-markdown-anabel-coello-perez-alu0100885200'...
[1] git clone https://github.com/ULL-MFP-AET-2122/latex-markdown-adela-gonzalez-maury-alu0101116204.git exited with code 0
[2] git clone https://github.com/ULL-MFP-AET-2122/latex-markdown-anabel-coello-perez-alu0100885200.git exited with code 0

Default Org Alias

I use this extension in combination with these two alias:

$ gh alias set cd '!gh config set current-org "$1" 2>/dev/null'
$ gh alias set pwd !'gh config get current-org'

Example of use:

$ gh cd ULL-MII-SYTWS-2122
$ gh pwd
ULL-MII-SYTWS-2122
$ gh cd ''
$ gh pwd

See also

gh-submodule-add's People

Contributors

crguezl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gh-submodule-add's Issues

Add gh extension cd

Proposal

gh cd <ownerregexp >

Sets the default org to the one that matches regexp. If several match they will be shown and the user will be asked to choose one.

will use gh config to do it

If ownerregexp is not specified it will change to user

Goal

From that moment on, all org related extensions will use that org by default

Storage

➜  gh-submodule-add git:(main) ✗ gh config set org 'ULL-ESIT-DMSI-1920'
! warning: 'org' is not a known configuration key
➜  gh-submodule-add git:(main) ✗ gh config get org
ULL-ESIT-DMSI-1920

the variable will be set to a JSON with a schema like this:

{
  "default": "default-owner",
 "orgs": [ "org1", "org2",  "..." ]
}

The command

gh cd update

updates the array of orgs

Builtin requirements

Hello could this tool be standalone or propose to install its dependencies on first run please?

So far I see that it needs 'fzf' and node's 'concurrently' package..

Strange failure for empty repository

If the submodule repository is empty I have this strange error:

Skipping to add repo https://github.com/hoeh/KC-features.git because is empty!
assert.js:101
  throw new AssertionError(obj);
  ^

AssertionError [ERR_ASSERTION]: [concurrently] no commands provided
    at concurrently (/home/heyho/Productions/KC/KC/node_modules/concurrently/dist/src/concurrently.js:34:22)
    at exports.default (/home/heyho/Productions/KC/KC/node_modules/concurrently/dist/src/index.js:34:44)
    at Object.<anonymous> (/home/heyho/Productions/KC/KC/node_modules/concurrently/dist/bin/concurrently.js:200:21)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47 {
  generatedMessage: false,
  code: 'ERR_ASSERTION',
  actual: 0,
  expected: 0,
  operator: 'notStrictEqual'
}
Error: Command "npx concurrently  -m 1 " failed
assert.js:101
  throw new AssertionError(obj);
  ^

AssertionError [ERR_ASSERTION]: [concurrently] no commands provided
    at concurrently (/home/heyho/Productions/KC/KC/node_modules/concurrently/dist/src/concurrently.js:34:22)
    at exports.default (/home/heyho/Productions/KC/KC/node_modules/concurrently/dist/src/index.js:34:44)
    at Object.<anonymous> (/home/heyho/Productions/KC/KC/node_modules/concurrently/dist/bin/concurrently.js:200:21)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47 {
  generatedMessage: false,
  code: 'ERR_ASSERTION',
  actual: 0,
  expected: 0,
  operator: 'notStrictEqual'
}

undefined
Inside urls.forEach
Skipping to add repo https://github.com/hoeh/KC-features.git because is empty!

option --assignment

Usage:

gh submodule-add --lab <org/searchquery> -r regexp

org is optional. See gh cd.

Downloads an assignment using clone by default

Will be equivalent to use the options:

-S assignment searchquery --clone-only -o org -r regexp

Downloads an assignment that matches regexp inside the org org

gh submodule-add -n --lab <org/query>

Shows what is going to be downloaded

  • Better to work as a simple clone by default

Add support for secure token storage

Token storage change in latest release of gh

This is a message from the GitHub CLI team, maintainers of gh, writing to inform you that the most recent release of gh contains changes which may affect your extension. The latest release introduces the feature of storing authentication tokens in the system keyring (encrypted storage) instead of in a plain text file.
The keyrings that are supported are:

  • Keychain on macOS

  • GNOME Keyring on Linux (Secret Service dbus interface)

  • Wincred on Windows

This has huge security benefits for the users of our tool and was one of our oldest outstanding issues. Unfortunately this change has the potential to break extensions that rely on utilizing the users authentication token to work.

In order to have continued compatibility with gh there are some actions you, as an extension author, need to take. These actions will depend on the implementation of your extension.

Extensions built in Go using go-gh:

  1. Upgrade your go-gh version to v1.2.1, the latest version.

  2. Verify that in your extension retrieval of the user authentication token is done using the auth.TokenForHost function.

    • If you were previously accessing the authentication token using any other method it will no longer work.
    • Automatic resolution of the authentication token when using the API clients will continue to work without changes.

All other extensions:

  1. Verify that in your extension retrieval of the user authentication token is done by shelling out to the gh auth token command.

    • If you were previously accessing the authentication token using the gh config get command, reading the configuration file directly, or any other methods it will no longer work.

As of right now storing the authentication token in the system keyring is an opt-in feature, but in the near future it will be required and at that point if the changes above are not made then your extension will be broken for all users. If you have any questions/concerns about this change please feel free to open a discussion in the gh repo.

Thanks,
The GitHub CLI Team

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.