Remix.run Logo
adityaathalye 5 hours ago

Nice... I made "Bulk Git Ops" Bash functions to source into shell and tab-complete to invoke. (nb. I organise my sources like this: ~/src/{github,gitlab,bitbucket}/{usernames..}/{reponames..}).

ref: bulk-git-ops.sh in my repo https://github.com/adityaathalye/bash-toolkit/

This way:

  Examples assume that repos you contribute to are spread across
  remote hosts, and (hopefully) namespaced sanely. I organise my
  sources as follows.

    ~/src/{github,gitlab,bitbucket}/{usernames..}/{reponames..}

  QUERY: Count repos that are stale:

    ls_git_projects ~/src/ | take_stale | count_repos_by_remote

  QUERY: Count repos that are active (within 12 hours by default):

    ls_git_projects ~/src/ | take_active | count_repos_by_remote


  EXECUTE! Use 'xgit' to apply simple git commands to the given repos, with logs to STDERR/stty

    ls_git_projects ~/src/bitbucket | xgit fetch # bitbucket-hosted repos

  EXECUTE! Use 'proc_repos' to apply custom functions to, with logs to STDERR/stty

    ls_git_projects ~/src/bitbucket | proc_repos git_fetch # all repos
    ls_git_projects ~/src/bitbucket | take_stale | proc_repos git_fetch # only stale repos
    ls_git_projects ~/src/bitbucket | take_active | proc_repos git_fetch # only active repos

  EXECUTE! What's the current branch? Logs to STDERR/stty

    ls_git_projects ~/src/bitbucket | proc_repos git_branch_current # all repos

  EXECUTE! With logs redirected to hidden dir for logging (you must create it by hand first)

    mkdir -p "${logdir}"
    ls_git_projects ~/src/bitbucket | proc_repos git_branch_current 2>> "${logdir}/bulkops.log"
    tail "${logdir}/bulkops.log"