๐Ÿ“ฆ antongolub / git-glob-cp

Glob-aware two-way copying for git

โ˜… 3 stars โ‘‚ 0 forks ๐Ÿ‘ 3 watching โš–๏ธ MIT License
gitglobutil
๐Ÿ“ฅ Clone https://github.com/antongolub/git-glob-cp.git
HTTPS git clone https://github.com/antongolub/git-glob-cp.git
SSH git clone git@github.com:antongolub/git-glob-cp.git
CLI gh repo clone antongolub/git-glob-cp
Anton Golub Anton Golub chore(release): 1.11.0 [skip ci] 1a9e43a 4 months ago ๐Ÿ“ History
๐Ÿ“‚ master View all commits โ†’
๐Ÿ“ .github
๐Ÿ“ src
๐Ÿ“„ .gitignore
๐Ÿ“„ CHANGELOG.md
๐Ÿ“„ LICENSE
๐Ÿ“„ package.json
๐Ÿ“„ README.md
๐Ÿ“„ vitest.config.js
๐Ÿ“„ yarn.lock
๐Ÿ“„ README.md

ggcp

git-glob-copy โ€” glob-aware two-way copying for git

Release Maintainability Test Coverage

Requirements

  • Node.js >= 16

Install

npm i git-glob-cp

# or as a global package
npm i -g ggcp

Usage

To perform various repos automations: bulk config reading, cascade template updating, etc.

CLI

# Copy `json` files from `master` branch of remote repo to local dir `temp`
git-glob-copy git@github.com:antongolub/tsc-esm-fix.git/master/*.json temp


# Push `json` files from local `.` dir to remote `json` branch
git-glob-copy *.json git@github.com:antongolub/tsc-esm-fix.git/master/json


# Push from repo to repo
ggcp 'git@github.com:antongolub/tsc-esm-fix.git/master/foo/*.txt' git@github.com:antongolub/git-glob-copy.git/master/bar


# Fetch remote archive to local dir
ggcp 'https://registry.npmjs.org/ggcp/-/ggcp-1.5.1.tgz/**/*.js' /private/tmp/ggcp-1.5.1/
ggcp is an alias for git-glob-copy

FlagDescriptionDefault
--message -mCommit messagechore: sync
--version -vPrint version
--help -hShow help
--ignore-files -iPath to ignoreFile (like .gitignore or .npmignore)
--cwd -CWorking directoryprocess.cwd()

Pattern examples

// Absolute dir path
'/foo/bar'

// Rel paths
'./foo/bar'
'foo/bar'

// Any depth md-filter
'./**/*.md'

// git://, git@, ssh://, https:// refs
'https://github.com/antongolub/tsc-esm-fix.git/master/*.json'
'ssh://github.com/antongolub/git-glob-cp.git/test/test'
'git@github.com:antongolub/git-glob-cp.git/master/foo/bar/**/*.js'
'git://github.com/antongolub/git-glob-cp.git/some-branch-name/test/**/*.js'
// repo ref                                 // branch        // glob pattern

'https://registry.npmjs.org/ggcp/-/ggcp-1.5.1.tgz/**/*.js'
// archive ref                                   // glob pattern

JS API

import { copy } from 'ggcp'

const from = 'git@github.com:antongolub/tsc-esm-fix.git/master/*.json'
const to = 'temp'
const msg = 'updated'
const ignoreFiles = '.gitignore'

// Copy any to any
await copy(from, to, msg, ignoreFiles)
await copy({from, to, msg, ignoreFiles}) // opts-based syntax

GitHub Actions

For example, push lcov.info from the coverage dir into the /<commit-sha> dir of the coverage branch of the remote repo.

- name: Store coverage
    run: |
      npm_config_yes=true npx ggcp lcov.info https://${{ secrets.GH_TOKEN }}@github.com/${{ github.repository }}.git/coverage/${{ github.sha }} --cwd=${{ github.workspace }}/coverage --message='chore: push coverage'

References

License

MIT