0.5.0 • Published 1 year ago

git-repo-generator v0.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

git-repo-generator

A CLI tool to generate Git repositories with specific configuration and commit histories, to quickly test your Git tools and workflows.

Quick Start

npx git-repo-generator

will generate in the current directory a Git repository with

  • A main branch
  • A test.txt file in the working directory
  • 3 commits
1--2--3  main

Options

npx git-repo-generator --dir repo-test --commits 5
OptionDescription
-d --dirDirectory of Git repository (default: . current directory )
-c --commitsNumber of commits (default: 3) Ignored if --file is provided (see below)
-f --fileConfiguration file (see below)
-h --helpDisplay command doc

Configuration file

You can provide a YAML file that describes your Git repo configuration and history

npx git-repo-generator -d repo-test -f git.yaml

Simple configuration file

log:
  - init
  - create file test.txt
  - commit
  - branch develop
  - checkout develop
  - create file test2.txt
  - commit
  - checkout main
  - merge develop
  - tag v1.0

will generate the following Git repository

  --2--    < develop
 /     \
1-------3  < main < v1.0

More complex configuration file

log:
  - init:
      defaultBranch: main
  - create file:
      file: test.txt
      content: line 1
  - commit:
      message: first commit
      author: user1
      email: user1@example.com
  - branch develop
  - checkout develop
  - change content:
      file: test.txt
      content: |
        line 1
        line 2
  - commit
  - checkout main
  - merge:
      theirs: develop
      message: merge commit
  - tag:
      name: v1.0
      annotated: true

conf:
  author: user
  email: user@example.com

Log commands

CommandExpressionsNotes
Init repository- init - init:   defaultBranch: masterIf omitted: - defaultBranch = "main"
Commit- commit - commit:   message: first commit   author: user1   email: user1@ex.comEquivalent of git add -a & git commit (stage all changes in the working dir before committing). If omitted: - message = "commit <#>" - author = conf.author ?? "user-test" - email = conf.email ?? "user-test@example.com"
Create branch- branch develop
Checkout- checkout develop
Merge- merge develop - merge:   theirs: develop   message: my merge commit   author: user1   email: user1@ex.comIf omitted: - message = "merge branch <theirs>" - author = conf.author ?? "user-test" - email = conf.email ?? "user-test@example.com" Merges never fast-forward. Merge conflicts are auto-resolved cleanly by favoring the "theirs" branch.
Tag- tag v1.0 - tag:   name: v1.0   annotated: true   message: new tag   author: user1   email: user1@ex.comBy default, creates a lightweight tag, unless annotated: trueIf omitted: - annotated = false - message = "create tag <name>" - author = conf.author ?? "user-test" - email = conf.email ?? "user-test@example.com"
Create file- create file src/test.txt - create file:   file: test.txt   content: file content - create file:   file: test.txt   content: |    line 1    line 2If omitted: - content = <file name>
Change content- change content:   file: test.txt   content: new file content

Configurations

conf:
  author: user # Default commit author name
  email: user@example.com # Default commit author email

License

MIT

Acknowledgements

  • isomorphic-git: for working with Git repositories (Great project. Check it out!)
0.5.0

1 year ago

0.4.0

1 year ago

0.3.0

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago