Skip to content

gh codespace and git status wrappers #16

Description

@isedwards

Implement a wrapper around GitHub CLI's gh codespace and git status -s:

  1. opencdms codespace status - show git status -s for all git repositories in /workspaces/

    Wrap the command below in Python

    find /workspaces -type d -name '.git' | while read dir ; do sh -c "cd $dir/../ && echo \"${dir//\.git/}\" && git status -s" ; done
    

    ... and only display lines starting with / if the next line does not start with '/'.

  2. opencdms codespace delete - delete current codespace if no changes in any repos in /workspaces/

    We can delete the current codespace container with:
    gh codespace delete -c $CODESPACE_NAME

    Offer -f and --force options to kill the container even if code changes exist.

Note:

  • Install GH cli with these instructions:
    type -p curl >/dev/null || sudo apt install curl -y
    curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
    && sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
    && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
    && sudo apt update \
    && sudo apt install gh -y
    

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions