First pass of organizing various data and scripts about a repository. One open question is seperation of data about a repository vs scripts that use that data.
Note that much of this doesn't currently work with various Git hosting services (for instance GitHub & GitLab put their files in .github/ .gitlab/ respectively). Instead, this is more of a proposal.
Git itself uses .git/hooks. but you can set git config core.hooksPath /path/to/your/hooks to the path you want.
Currently I'm leaning to .repo as the name for the root directory of this stack.
.repo/
│
├── hooks/
│ ├── pre-commit.sh
│ ├── pre-push.sh
│ ├── commit-msg.sh
│ ├── post-merge
│ └── (etc.)
│
├── scripts/
│ ├── verify_commit_signers.sh
│ ├── verify_tag_signers.sh
│ ├── verify_release_signers.sh
│ ├── deploy_helpers.sh
│ ├── setup_environment.sh
│ └── security_checks.sh
│
├── config/
│ ├── pipeline/
│ │ ├── github_actions.yml
│ │ ├── gitlab_ci.yml
│ │ └── bitbucket_pipelines.yml
│ ├── environment/
│ │ ├── prod_env_settings.env
│ │ └── test_env_settings.env
│ └── verification/
│ ├── allowed_commit_signers.txt
│ ├── allowed_tag_signers.txt
│ └──trust-manifest.env
│
├── docs/
│ ├── README.md
│ ├── config_guide.md
│ ├── setup_instructions.md
│ └── usage_guidelines.md
│
└── monitoring/
├── log_analysis.py
└── performance_monitoring.sh
-
Hooks:
- The
hooks/directory straightforwardly contains all Git hooks used in the repository. This setup aligns with thegit config core.hooksPathcommand pointing to this folder, enabling direct application of these hooks without additional configuration.
- The
-
Scripts:
- The
scripts/directory holds all executable scripts related to deployment, verification, and security checks. This separation ensures that scripts are easily manageable and clearly differentiated from configuration data.
- The
-
Config:
- This directory is divided into subdirectories for different configurations:
pipeline/contains CI/CD configurations for various platforms.environment/holds environment-specific settings.verification/stores data files like allowed signers which are crucial for commit validation processes.
- This organization ensures that configuration data is kept separate from scripts, enhancing security and clarity.
- This directory is divided into subdirectories for different configurations:
-
Docs:
- Documentation related to the repository’s structure, script usage, and configuration guidelines is stored here, providing a central location for all informational content.
-
Monitoring:
- Includes scripts for log analysis and performance monitoring, ensuring that operational aspects of the repository are monitored and maintained effectively.
- Clarity and Accessibility: The structure is clear, with a logical separation of hooks, scripts, configuration data, and documentation.
- Security and Integrity: By separating executable scripts from configuration data, the repository maintains high security and integrity standards, crucial for operations like commit validation and code review.
- Scalability and Flexibility: This structure allows easy updates and additions in scripts and configurations without affecting other repository areas, supporting scalability.
In a Git repository, several types of hooks can be used to trigger custom scripts at various points in the Git lifecycle. Each hook corresponds to a particular operation within Git and can be placed in the .git/hooks folder.
- pre-commit: Runs before a commit is recorded, allowing you to run checks on the changes to be committed.
- prepare-commit-msg: Runs before the commit message editor is opened, allowing you to modify the default commit message.
- commit-msg: Runs after the commit message is written, allowing you to check the contents of the message.
- post-commit: Runs after a commit is completed, useful for notification or other post-commit operations.
- pre-rebase: Runs before a rebase operation starts, giving you a chance to prevent the rebase if necessary.
- post-checkout: Runs after a successful checkout, useful for setting up the working directory properly for your project environment.
- post-merge: Runs after a successful merge, useful for restoring project state or dependencies altered by the merge.
- pre-push: Runs during
git push, before any objects are transferred, allowing you to run tests or checks. - pre-auto-gc: Runs automatically before the garbage collection process, which is generally triggered by other commands.
- pre-receive: Runs before any commits are accepted into the repository, allowing you to enforce project standards or perform checks.
- update: Runs once for each branch being pushed to check if the push should be accepted.
- post-receive: Runs after all branches and their refs have been updated on the server, often used to update other services or send notifications.
- reference-transaction: Runs during a reference transaction, which can be either during the update of a reference or during the creation/deletion of a reference.
- push-to-checkout: Invoked on the server when a push tries to update a ref that is currently checked out.
- post-index-change: Runs after the staging area (index) is updated.
Here is a comprehensive list of standard repository files supported by GitHub, GitLab, and Bitbucket, including those within their specific directories like .github/ or .gitlab/:
- README.md - Provides essential information about the project.
- LICENSE.md - Details the licensing terms of the project.
- .gitignore - Specifies intentionally untracked files to ignore.
- .gitattributes - Helps manage attributes of the paths in the Git repository.
- .github/ - Contains GitHub-specific files like issue and pull request templates:
- ISSUE_TEMPLATE/ - For custom issue templates.
- PULL_REQUEST_TEMPLATE.md - Templates for pull requests.
- CODEOWNERS - Specifies individuals or teams responsible for code in the repository.
- FUNDING.yml - Displays a sponsor button to increase the visibility of funding options.
- CODE_OF_CONDUCT.md - Standards for how to engage in the community.
- CONTRIBUTING.md - Guidelines on how to contribute to the project.
- SECURITY.md - Security policy and reporting guidelines.
- workflows/ - For GitHub Actions CI/CD configuration files.
- .gitlab-ci.yml - GitLab CI/CD configuration file.
- .gitlab/ - Directory for GitLab-specific templates and configuration:
- issue_templates/ - Custom issue templates.
- merge_request_templates/ - Templates for merge requests.
- bitbucket-pipelines.yml - Bitbucket Pipelines CI/CD configuration file.
- .bitbucket/ - Contains Bitbucket-specific configurations (less commonly used compared to GitHub and GitLab).