├── .editorconfig ├── .envrc ├── .gitattributes ├── .github ├── CODEOWNERS └── workflows │ ├── ci.yml │ └── stale.yml ├── .gitignore ├── .markdownlint-cli2.yaml ├── .mdlrc ├── .overcommit.yml ├── .vscode └── extensions.json ├── .yamllint ├── Berksfile ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Dangerfile ├── LICENSE ├── README.md ├── TESTING.md ├── attributes └── default.rb ├── chefignore ├── documentation ├── .gitkeep ├── git_client.md └── git_config.md ├── kitchen.dokken.yml ├── kitchen.exec.yml ├── kitchen.global.yml ├── kitchen.yml ├── libraries └── helpers.rb ├── metadata.rb ├── recipes ├── default.rb ├── package.rb ├── source.rb └── windows.rb ├── renovate.json ├── resources ├── client_linux.rb ├── client_osx.rb ├── client_windows.rb └── config.rb ├── spec ├── spec_helper.rb └── unit │ └── recipes │ ├── default_spec.rb │ ├── source_spec.rb │ └── windows_spec.rb ├── templates └── git-xinetd.d.erb └── test ├── fixtures └── cookbooks │ └── test │ ├── metadata.rb │ └── recipes │ ├── default.rb │ ├── server.rb │ └── source.rb └── integration ├── resources └── git_installed_spec.rb ├── server └── git_daemon_spec.rb └── source └── git_installed_spec.rb /.editorconfig: -------------------------------------------------------------------------------- 1 | # https://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root=true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | 11 | # 2 space indentation 12 | indent_style = space 13 | indent_size = 2 14 | 15 | # Avoid issues parsing cookbook files later 16 | charset = utf-8 17 | 18 | # Avoid cookstyle warnings 19 | trim_trailing_whitespace = true 20 | -------------------------------------------------------------------------------- /.envrc: -------------------------------------------------------------------------------- 1 | use chefworkstation 2 | export KITCHEN_GLOBAL_YAML=kitchen.global.yml 3 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @sous-chefs/maintainers 2 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: ci 3 | 4 | "on": 5 | pull_request: 6 | push: 7 | branches: [main] 8 | 9 | jobs: 10 | lint-unit: 11 | uses: sous-chefs/.github/.github/workflows/lint-unit.yml@3.1.1 12 | permissions: 13 | actions: write 14 | checks: write 15 | pull-requests: write 16 | statuses: write 17 | issues: write 18 | 19 | integration: 20 | needs: lint-unit 21 | runs-on: ubuntu-latest 22 | strategy: 23 | matrix: 24 | os: 25 | - almalinux-8 26 | - amazonlinux-2 27 | - centos-7 28 | - centos-stream-8 29 | - debian-10 30 | - debian-11 31 | - opensuse-leap-15 32 | - rockylinux-8 33 | - ubuntu-1804 34 | - ubuntu-2004 35 | suite: 36 | - resources 37 | - source 38 | fail-fast: false 39 | 40 | steps: 41 | - name: Check out code 42 | uses: actions/checkout@v4 # v4 43 | - name: Install Chef 44 | uses: actionshub/chef-install@3.0.0 45 | - name: Dokken 46 | uses: actionshub/test-kitchen@3.0.0 47 | env: 48 | CHEF_LICENSE: accept-no-persist 49 | KITCHEN_LOCAL_YAML: kitchen.dokken.yml 50 | with: 51 | suite: ${{ matrix.suite }} 52 | os: ${{ matrix.os }} 53 | - name: Print debug output on failure 54 | if: failure() 55 | run: | 56 | set -x 57 | sudo journalctl -l --since today 58 | KITCHEN_LOCAL_YAML=kitchen.dokken.yml /usr/bin/kitchen exec ${{ matrix.suite }}-${{ matrix.os }} -c "journalctl -l" 59 | 60 | integration-windows: 61 | needs: lint-unit 62 | runs-on: macos-latest 63 | strategy: 64 | matrix: 65 | os: 66 | - windows-2016 67 | - windows-2019 68 | suite: 69 | - resources 70 | fail-fast: false 71 | 72 | steps: 73 | - name: Check out code 74 | uses: actions/checkout@v4 # v4 75 | - name: Install Chef 76 | uses: actionshub/chef-install@3.0.0 77 | - name: test-kitchen 78 | uses: actionshub/test-kitchen@3.0.0 79 | env: 80 | CHEF_LICENSE: accept-no-persist 81 | with: 82 | suite: ${{ matrix.suite }} 83 | os: ${{ matrix.os }} 84 | 85 | integration-macos: 86 | needs: lint-unit 87 | runs-on: macos-latest 88 | strategy: 89 | matrix: 90 | os: 91 | - macos-latest 92 | suite: 93 | - resources 94 | fail-fast: false 95 | 96 | steps: 97 | - name: Check out code 98 | uses: actions/checkout@v4 # v4 99 | - name: Install Chef 100 | uses: actionshub/chef-install@3.0.0 101 | - name: test-kitchen 102 | uses: actionshub/test-kitchen@3.0.0 103 | env: 104 | CHEF_LICENSE: accept-no-persist 105 | KITCHEN_LOCAL_YAML: kitchen.exec.yml 106 | with: 107 | suite: ${{ matrix.suite }} 108 | os: ${{ matrix.os }} 109 | 110 | results: 111 | if: ${{ always() }} 112 | runs-on: ubuntu-latest 113 | name: Final Results 114 | needs: [integration, integration-macos, integration-windows] 115 | steps: 116 | - run: | 117 | results=( 118 | "${{ needs.integration.result }}" 119 | "${{ needs.integration-macos.result }}" 120 | "${{ needs.integration-windows.result }}" 121 | ) 122 | 123 | for exit_code in $results; do 124 | if [[ $exit_code != "success" && $exit_code != "skipped" ]]; then 125 | exit 1 126 | fi 127 | done 128 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Mark stale issues and pull requests 3 | 4 | "on": 5 | schedule: [cron: "0 0 * * *"] 6 | 7 | jobs: 8 | stale: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/stale@v9 12 | with: 13 | repo-token: ${{ secrets.GITHUB_TOKEN }} 14 | close-issue-message: > 15 | Closing due to inactivity. 16 | If this is still an issue please reopen or open another issue. 17 | Alternatively drop by the #sous-chefs channel on the [Chef Community Slack](http://community-slack.chef.io/) and we'll be happy to help! 18 | Thanks, Sous-Chefs. 19 | days-before-close: 7 20 | days-before-stale: 365 21 | stale-issue-message: > 22 | Marking stale due to inactivity. 23 | Remove stale label or comment or this will be closed in 7 days. 24 | Alternatively drop by the #sous-chefs channel on the [Chef Community Slack](http://community-slack.chef.io/) and we'll be happy to help! 25 | Thanks, Sous-Chefs. 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.rbc 2 | .config 3 | InstalledFiles 4 | pkg 5 | test/tmp 6 | test/version_tmp 7 | tmp 8 | _Store 9 | *~ 10 | *# 11 | .#* 12 | \#*# 13 | *.un~ 14 | *.tmp 15 | *.bk 16 | *.bkup 17 | 18 | # editor files 19 | .idea 20 | .*.sw[a-z] 21 | 22 | # ruby/bundler/rspec files 23 | .ruby-version 24 | .ruby-gemset 25 | .rvmrc 26 | Gemfile.lock 27 | .bundle 28 | *.gem 29 | coverage 30 | spec/reports 31 | 32 | # YARD / rdoc artifacts 33 | .yardoc 34 | _yardoc 35 | doc/ 36 | rdoc 37 | 38 | # chef infra stuff 39 | Berksfile.lock 40 | .kitchen 41 | kitchen.local.yml 42 | vendor/ 43 | .coverage/ 44 | .zero-knife.rb 45 | Policyfile.lock.json 46 | 47 | # vagrant stuff 48 | .vagrant/ 49 | .vagrant.d/ 50 | -------------------------------------------------------------------------------- /.markdownlint-cli2.yaml: -------------------------------------------------------------------------------- 1 | config: 2 | ul-indent: false # MD007 3 | line-length: false # MD013 4 | no-duplicate-heading: false # MD024 5 | reference-links-images: false # MD052 6 | ignores: 7 | - .github/copilot-instructions.md 8 | -------------------------------------------------------------------------------- /.mdlrc: -------------------------------------------------------------------------------- 1 | rules "~MD013", "~MD024", "~MD025" 2 | -------------------------------------------------------------------------------- /.overcommit.yml: -------------------------------------------------------------------------------- 1 | --- 2 | PreCommit: 3 | TrailingWhitespace: 4 | enabled: true 5 | YamlLint: 6 | enabled: true 7 | required_executable: "yamllint" 8 | ChefSpec: 9 | enabled: true 10 | required_executable: "chef" 11 | command: ["chef", "exec", "rspec"] 12 | Cookstyle: 13 | enabled: true 14 | required_executable: "cookstyle" 15 | command: ["cookstyle"] 16 | MarkdownLint: 17 | enabled: false 18 | required_executable: "npx" 19 | command: ["npx", "markdownlint-cli2", "'**/*.md'"] 20 | include: ["**/*.md"] 21 | 22 | CommitMsg: 23 | HardTabs: 24 | enabled: true 25 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "chef-software.chef", 4 | "rebornix.ruby", 5 | "editorconfig.editorconfig", 6 | "DavidAnson.vscode-markdownlint" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /.yamllint: -------------------------------------------------------------------------------- 1 | --- 2 | extends: default 3 | rules: 4 | line-length: 5 | max: 256 6 | level: warning 7 | document-start: disable 8 | braces: 9 | forbid: false 10 | min-spaces-inside: 0 11 | max-spaces-inside: 1 12 | min-spaces-inside-empty: -1 13 | max-spaces-inside-empty: -1 14 | comments: 15 | min-spaces-from-content: 1 16 | -------------------------------------------------------------------------------- /Berksfile: -------------------------------------------------------------------------------- 1 | source 'https://supermarket.chef.io' 2 | 3 | metadata 4 | 5 | group :integration do 6 | cookbook 'homebrew' 7 | cookbook 'test', path: 'test/fixtures/cookbooks/test' 8 | end 9 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # git Cookbook CHANGELOG 2 | 3 | This file is used to list changes made in each version of the git cookbook. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 | 8 | ## Unreleased 9 | 10 | ## 12.1.7 - *2024-11-18* 11 | 12 | Standardise files with files in sous-chefs/repo-management 13 | 14 | Standardise files with files in sous-chefs/repo-management 15 | 16 | ## 12.1.6 - *2024-07-15* 17 | 18 | Standardise files with files in sous-chefs/repo-management 19 | 20 | Standardise files with files in sous-chefs/repo-management 21 | 22 | Standardise files with files in sous-chefs/repo-management 23 | 24 | ## 12.1.5 - *2024-05-02* 25 | 26 | ## 12.1.4 - *2024-05-02* 27 | 28 | ## 12.1.3 - *2023-09-28* 29 | 30 | ## 12.1.2 - *2023-09-04* 31 | 32 | ## 12.1.1 - *2023-07-10* 33 | 34 | ## 12.1.0 - *2023-05-18* 35 | 36 | - Add the 'file' scope 37 | 38 | ## 12.0.0 - *2023-05-18* 39 | 40 | - Remove service resource 41 | - Remove server recipe 42 | The server recipe was insecure and not a recommended way of runing a Git service 43 | - Remove links to tickets.chef.io 44 | 45 | ## 11.2.9 - *2023-05-16* 46 | 47 | ## 11.2.8 - *2023-05-16* 48 | 49 | Standardise files with files in sous-chefs/repo-management 50 | 51 | ## 11.2.7 - *2023-04-17* 52 | 53 | ## 11.2.6 - *2023-04-07* 54 | 55 | Standardise files with files in sous-chefs/repo-management 56 | 57 | ## 11.2.5 - *2023-04-01* 58 | 59 | ## 11.2.4 - *2023-04-01* 60 | 61 | ## 11.2.3 - *2023-04-01* 62 | 63 | Standardise files with files in sous-chefs/repo-management 64 | 65 | ## 11.2.2 - *2023-03-02* 66 | 67 | ## 11.2.1 - *2023-03-02* 68 | 69 | Standardise files with files in sous-chefs/repo-management 70 | 71 | ## 11.2.0 - *2023-02-27* 72 | 73 | Update to the version number and hash for 32-bit/64-bit windows 74 | 75 | ## 11.1.6 - *2023-02-27* 76 | 77 | Standardise files with files in sous-chefs/repo-management 78 | 79 | ## 11.1.5 - *2023-02-16* 80 | 81 | Standardise files with files in sous-chefs/repo-management 82 | 83 | ## 11.1.4 - *2023-02-14* 84 | 85 | Standardise files with files in sous-chefs/repo-management 86 | 87 | ## 11.1.3 - *2022-12-08* 88 | 89 | Standardise files with files in sous-chefs/repo-management 90 | 91 | ## 11.1.2 - *2022-10-14* 92 | 93 | - Fix package name for smartos/omnios 94 | 95 | ## 11.1.1 - *2022-08-30* 96 | 97 | - Fix Windows default git checksum 98 | 99 | ## 11.1.0 - *2022-08-09* 100 | 101 | - Standardise files with files in sous-chefs/repo-management 102 | - Update tested platforms 103 | - Update Windows version to 2.35.1 104 | - Update helpers to deal with 32/64bit 105 | - Switch `git::package` to use `git_client` for windows 106 | - Remove inclusion of `git::default` from `git_config` resource 107 | - Add `password` property to `git_config` resource which is required on Windows if running as a different user 108 | - Fix tests on MacOS and Windows 109 | 110 | ## 11.0.2 - *2022-05-16* 111 | 112 | - Remove delivery folder 113 | - Use reuable workflows 114 | 115 | ## 11.0.1 - *2021-08-30* 116 | 117 | - Standardise files with files in sous-chefs/repo-management 118 | 119 | ## 11.0.0 - *2021-07-31* 120 | 121 | - Enable `unified_mode` for Chef 17 compatibility 122 | - Add some missing test coverage 123 | - Convert `git_service` LWRP to custom resource 124 | - Convert `git_client` LWRP to custom resource 125 | - **BREAKING**: source provider changed to `:install_from_source` action 126 | - use `ark` cookbook for source install 127 | 128 | ## 10.1.0 (2020-10-12) 129 | 130 | - Sous Chefs Adoption 131 | - Update Changelog to Sous Chefs 132 | - Update to use Sous Chefs GH workflow 133 | - Update README to sous-chefs 134 | - Update metadata.rb to Sous Chefs 135 | - Update test-kitchen to Sous Chefs 136 | 137 | ### Fixes 138 | 139 | - Cookstyle fixes 140 | - Yamllint fixes 141 | - Fix `git_service` on various systemd platforms 142 | - Fix idempotency issues with xinetd service 143 | 144 | - Include mdlrc file 145 | - Add testing for Ubuntu 20.04 146 | 147 | - Remove support for Amazon Linux 1 148 | - Remove support for CentOS 6 149 | 150 | ## 10.0.0 (2019-10-16) 151 | 152 | - Add testing for CentOS 8, openSUSE 15, Ubuntu 18.04 in Travis 153 | - Require Chef Infra Client 14 or later so we can drop the dependency on build-essential 154 | - Resolve multiple cookstyle warnings 155 | 156 | ## 9.0.1 (2018-06-02) 157 | 158 | - Update the platforms we test on 159 | - Remove extra attr_accessor in config and requires 160 | - Bump git version to 2.17.1 to resolve CVE 161 | 162 | ## 9.0.0 (2018-03-08) 163 | 164 | - Remove the dependency on the homebrew cookbook by not automatically installing homebrew in the git resource on macOS systems. Homebrew needs to be setup before this resource runs and that should probably be the very first thing you do on a macOS system 165 | - Use the build_essential resource instead of including the default recipe. This requires version 5.0 or later of the build-essential cookbook and allows us to use the build_essential resource that will be built into Chef 14 when that ships 166 | - Remove extra includes in the resources that weren't necessary 167 | - Updated testing to include Fedora 27, Ubuntu 18.04, Debian 9, macOS 10.12, and Windows 2016 168 | 169 | ## 8.0.1 (2018-02-10) 170 | 171 | - Resolve the new FC118 foodcritic warning 172 | - Remove the ChefSpec matchers which are auto generated now 173 | - Resolve FC104 warning 174 | 175 | ## 8.0.0 (2017-09-01) 176 | 177 | ### Breaking Changes 178 | 179 | - macOS resource now properly executes and uses homebrew to install git instead of dmg and packages posted to SourceForge 180 | - Default to Git 2.9.5 now, which properly compiles on Fedora / Amazon Linux 181 | 182 | ## Other Changes 183 | 184 | - Fixed support for Amazon Linux on Chef 13 185 | - Unified the package setup for source installs which fixes Amazon/Fedora 186 | - Removed an entirely duplicate service provider 187 | - Remove unused runit templates 188 | - Properly fail when we're on an unsupported platform 189 | 190 | ## 7.0.0 (2017-09-01) 191 | 192 | - Remove support for RHEL 5 which removes the need for the yum-epel cookbook 193 | - Move templates out of the default directory now that we require Chef 12 194 | - Remove support for Ubuntu 10.04 195 | - Remove the version requirement on mac_os_x in the metadata 196 | - Move maintainer information to the readme 197 | - Expand Travis testing 198 | 199 | ## 6.1.0 (2017-05-30) 200 | 201 | - Test with Local Delivery and not Rake 202 | - Remove EOL platforms from the kitchen configs 203 | - Use a SPDX standard license string 204 | - Updated default versions documented in README to fix Issue #120. 205 | - Remove class_eval and require chef 12.7+ 206 | 207 | ## 6.0.0 (2017-02-14) 208 | 209 | - Fail on deprecations is now enabled so we're fully Chef 13 compatible 210 | - Define the chefspec matchers properly 211 | - Remove the legacy platform mappings that fail on Chef 13 212 | - Improve the test cookbook / integration tests 213 | - Convert config LWRP to a custom resource and make it fully idempotent 214 | - Require Chef 12.5 or later 215 | 216 | ## 5.0.2 (2017-01-18) 217 | 218 | - Remove arch for the metadata 219 | - Avoid deprecation warning during testing 220 | - respond_to?(:chef_version) for < 12.6 compat 221 | 222 | ## 5.0.1 (2016-09-15) 223 | 224 | - Clarify we require Chef 12.1 or later 225 | 226 | ## 5.0.0 (2016-09-02) 227 | 228 | - Require Chef 12 or later 229 | - Don't depend on the windows cookbook since windows_package is built into Chef 12 230 | - Updates for testing 231 | 232 | ## v4.6.0 (2016-07-05) 233 | 234 | - Added support for compiling git on suse 235 | - Added the ability to pass a new group property to the config provider 236 | - Documented the git_config provider 237 | - Added the tar package on RHEL/Fedora for source installs as some minimal installs lack this package 238 | - Added suse, opensuse, and opensuseleap as supported platforms in the metadata 239 | - Switched to inspec for testing 240 | - Switched to cookstyle for Ruby linting 241 | - Added Travis integration testing of Debian 7/8 242 | 243 | ## v4.5.0 (2016-04-28) 244 | 245 | - Update git versions to 2.8.1 246 | 247 | ## v4.4.1 (2016-03-31) 248 | 249 | - PR #95 support 32 bit and 64 bit installs on windows @smurawski 250 | 251 | ## v4.4.0 (2016-03-23) 252 | 253 | - PR #93 bump to latest git @ksubrama 254 | 255 | ## v4.3.7 (2016-02-03) 256 | 257 | - PR #90 port node[git][server][export_all] to true/false @scalp42 258 | - PR #89 make attributes more wrapper friendly @scalp42 259 | - Update testing deps + rubocop fixes 260 | - README fix @zverulacis 261 | 262 | ## v4.3.6 (2016-01-25) 263 | 264 | - Windows fixes 265 | 266 | ## v4.3.5 (2015-12-15) 267 | 268 | - Fixed installation on Windows nodes 269 | - Removed the last of the Chef 10 compatibility code 270 | - Added up to date contributing and testing docs 271 | - Updated test deps in the Gemfile 272 | - Removed test kitchen digital ocean config 273 | - Test with kitchen-docker in Travis CI 274 | - Removed uncessary windows cookbook entry from the Berksfile 275 | - Added the chef standard rubocop.yml file and resolved all warnings 276 | - Added chefignore file 277 | - Removed bin dir 278 | - Added maintainers.md and maintainers.toml files 279 | - Added travis and supermarket version badges to the readme 280 | 281 | ## v4.3.4 (2015-09-06) 282 | 283 | - Fixing package_id on OSX 284 | - Adding 2.5.1 data for Windows 285 | 286 | ## v4.3.3 (2015-07-27) 287 | 288 | - #76: Use checksum keyname instead of value in source recipe 289 | 290 | ## v4.3.2 (2015-07-27) 291 | 292 | - Fixing up Windows provider (issue #73) 293 | - Supporting changes to source_prefix in source provider (#62) 294 | 295 | ## v4.3.1 (2015-07-23) 296 | 297 | - Fixing up osx_dmg_source_url 298 | 299 | ## v4.3.0 (2015-07-20) 300 | 301 | - Removing references to node attributes from provider code 302 | - Name-spacing of client resource property names 303 | - Addition of windows recipe 304 | - Creation of package recipe 305 | 306 | ## v4.2.4 (2015-07-19) 307 | 308 | - Fixing source provider selection bug from 4.2.3 309 | 310 | ## v4.2.3 (2015-07-18) 311 | 312 | - mac_os_x provider mapping 313 | - various rubocops 314 | 315 | ## v4.2.2 (2015-04-23) 316 | 317 | - Fix up action in Chef::Resource::GitService 318 | - Adding matchers 319 | 320 | ## v4.2.1 (2015-04-17) 321 | 322 | - Fixing Chef 11 support. 323 | - Adding provider mapping file 324 | 325 | ## v4.2.0 (2015-04-15) 326 | 327 | - Converting recipes to resources. 328 | - Keeping recipe interface for backwards compat 329 | 330 | ## v4.1.0 (2014-12-23) 331 | 332 | - Fixing windows package checksums 333 | - Various test coverage additions 334 | 335 | ## v4.0.2 (2014-04-23) 336 | 337 | - [COOK-4482] - Add FreeBSD support for installing git client 338 | 339 | ## v4.0.0 (2014-03-18) 340 | 341 | - [COOK-4397] Only use_inline_resources on Chef 11 342 | 343 | ## v3.1.0 (2014-03-12) 344 | 345 | - [COOK-4392] - Cleanup git_config LWRP 346 | 347 | ## v3.0.0 (2014-02-28) 348 | 349 | [COOK-4387] Add git_config type [COOK-4388] Fix up rubocops [COOK-4390] Add integration tests for default and server suites 350 | 351 | ## v2.10.0 (2014-02-25) 352 | 353 | - [COOK-4146] - wrong dependency in git::source for rhel 6 354 | - [COOK-3947] - Git cookbook adds itself to the path every run 355 | 356 | ## v2.9.0 357 | 358 | Updating to depend on cookbook yum ~> 3 Fixing style to pass rubocop Updating test scaffolding 359 | 360 | ## v2.8.4 361 | 362 | fixing metadata version error. locking to 3.0 363 | 364 | ## v2.8.1 365 | 366 | Locking yum dependency to '< 3' 367 | 368 | ## v2.8.0 369 | 370 | - git::server does not correctly set git-daemon's base-path on Debian 371 | 372 | ## v2.7.0 373 | 374 | - Don't restart `xinetd` on each Chef client run 375 | - Force git to add itself to the current process' PATH 376 | 377 | ### New Feature 378 | 379 | - Support Omnios and SmartOS package installs 380 | 381 | ## v2.6.0 382 | 383 | ### Improvement 384 | 385 | - Add proper debian packages 386 | 387 | ## v2.5.2 388 | 389 | - [COOK-2813]: Fix bad string interpolation in source recipe 390 | 391 | ## v2.5.0 392 | 393 | - Relax runit version constraint (now depend on 1.0+). 394 | 395 | ## v2.4.0 396 | 397 | - [COOK-2734] - update git versions 398 | 399 | ## v2.3.0 400 | 401 | - [COOK-2385] - update git::server for `runit_service` resource support 402 | 403 | ## v2.2.0 404 | 405 | - [COOK-2303] - git::server support for RHEL `platform_family` 406 | 407 | ## v2.1.4 408 | 409 | - [COOK-2110] - initial test-kitchen support (only available in GitHub repository) 410 | - [COOK-2253] - pin runit dependency 411 | 412 | ## v2.1.2 413 | 414 | - [COOK-2043] - install git on ubuntu 12.04 not git-core 415 | 416 | ## v2.1.0 417 | 418 | The repository didn't have pushed commits, and so the following changes from earlier-than-latest versions wouldn't be available on the community site. We're releasing 2.1.0 to correct this. 419 | 420 | - [COOK-1943] - Update to git 1.8.0 421 | - [COOK-2020] - Add setup option attributes to Git Windows package install 422 | 423 | ## v2.0.0 424 | 425 | This version uses `platform_family` attribute, making the cookbook incompatible with older versions of Chef/Ohai, hence the major version bump. 426 | 427 | - [COOK-1668] - git cookbook fails to run due to bad `platform_family` call 428 | - [COOK-1759] - git::source needs additional package for rhel `platform_family` 429 | 430 | ## v1.1.2 431 | 432 | - [COOK-2020] - Add setup option attributes to Git Windows package install 433 | 434 | ## v1.1.0 435 | 436 | - [COOK-1943] - Update to git 1.8.0 437 | 438 | ## v1.0.2 439 | 440 | - [COOK-1537] - add recipe for source installation 441 | 442 | ## v1.0.0 443 | 444 | - [COOK-1152] - Add support for Mac OS X 445 | - [COOK-1112] - Add support for Windows 446 | 447 | ## v0.10.0 448 | 449 | - [COOK-853] - Git client installation on CentOS 450 | 451 | ## v0.9.0 452 | 453 | - Current public release 454 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Community Guidelines 2 | 3 | This project follows the Chef Community Guidelines 4 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Please refer to 4 | [https://github.com/chef-cookbooks/community_cookbook_documentation/blob/main/CONTRIBUTING.MD](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/main/CONTRIBUTING.MD) 5 | -------------------------------------------------------------------------------- /Dangerfile: -------------------------------------------------------------------------------- 1 | # Reference: http://danger.systems/reference.html 2 | 3 | # A pull request summary is required. Add a description of the pull request purpose. 4 | # Changelog must be updated for each pull request that changes code. 5 | # Warnings will be issued for: 6 | # Pull request with more than 400 lines of code changed 7 | # Pull reqest that change more than 5 lines without test changes 8 | # Failures will be issued for: 9 | # Pull request without summary 10 | # Pull requests with code changes without changelog entry 11 | 12 | def code_changes? 13 | code = %w(libraries attributes recipes resources files templates) 14 | code.each do |location| 15 | return true unless git.modified_files.grep(/#{location}/).empty? 16 | end 17 | false 18 | end 19 | 20 | def test_changes? 21 | tests = %w(spec test kitchen.yml kitchen.dokken.yml) 22 | tests.each do |location| 23 | return true unless git.modified_files.grep(/#{location}/).empty? 24 | end 25 | false 26 | end 27 | 28 | failure 'Please provide a summary of your Pull Request.' if github.pr_body.length < 10 29 | 30 | warn 'This is a big Pull Request.' if git.lines_of_code > 400 31 | 32 | warn 'This is a Table Flip.' if git.lines_of_code > 2000 33 | 34 | # Require a CHANGELOG entry for non-test changes. 35 | if !git.modified_files.include?('CHANGELOG.md') && code_changes? 36 | failure 'Please include a CHANGELOG entry.' 37 | end 38 | 39 | # Require Major Minor Patch version labels 40 | unless github.pr_labels.grep /minor|major|patch/i 41 | warn 'Please add a release label to this pull request' 42 | end 43 | 44 | # A sanity check for tests. 45 | if git.lines_of_code > 5 && code_changes? && !test_changes? 46 | warn 'This Pull Request is probably missing tests.' 47 | end 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Git Cookbook 2 | 3 | [![Cookbook Version](https://img.shields.io/cookbook/v/git.svg)](https://supermarket.chef.io/cookbooks/git) 4 | [![CI State](https://github.com/sous-chefs/git/workflows/ci/badge.svg)](https://github.com/sous-chefs/git/actions?query=workflow%3Aci) 5 | [![OpenCollective](https://opencollective.com/sous-chefs/backers/badge.svg)](#backers) 6 | [![OpenCollective](https://opencollective.com/sous-chefs/sponsors/badge.svg)](#sponsors) 7 | [![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0) 8 | 9 | Installs git_client from package or source. Optionally sets up a git service under xinetd. 10 | 11 | ## Scope 12 | 13 | This cookbook is concerned with the Git SCM utility. It does not address ecosystem tooling or related projects. 14 | 15 | ## Maintainers 16 | 17 | This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. If you’d like to know more please visit [sous-chefs.org](https://sous-chefs.org/) or come chat with us on the Chef Community Slack in [#sous-chefs](https://chefcommunity.slack.com/messages/C2V7B88SF). 18 | 19 | ## Requirements 20 | 21 | ### Chef 22 | 23 | - Chef 15.3+ 24 | 25 | ### Cookbooks 26 | 27 | - ark (for `git_client` source install) 28 | 29 | ## Usage 30 | 31 | Include `git::default`, `git::windows`, or `git::source` in your cookbook OR use the `git_client` resource directly. 32 | 33 | ## Resources Overview 34 | 35 | - [`git_client`](./documentation/git_client.md): Manages a Git client installation on a machine. Source install action is available on Linux. 36 | - [`git_config`](./documentation/git_config.md): Sets up Git configuration on a node. 37 | 38 | ## Recipes 39 | 40 | This cookbook ships with ready to use, attribute driven recipes that utilize the `git_client` and `git_service` resources. As of cookbook 4.x, they utilize the same attributes layout scheme from the 3.x. Due to some overlap, it is currently impossible to simultaneously install the Git client as a package and from source by using the "manipulate the node attributes and run a recipe" technique. If you need both, you'll need to utilize the git_client resource in a recipe. 41 | 42 | ## Attributes 43 | 44 | ### Windows 45 | 46 | - `node['git']['version']` - git version to install 47 | - `node['git']['url']` - URL to git package 48 | - `node['git']['checksum']` - package SHA256 checksum 49 | - `node['git']['display_name']` - `windows_package` resource Display Name (makes the package install idempotent) 50 | 51 | ### Linux 52 | 53 | - `node['git']['prefix']` - git install directory 54 | - `node['git']['version']` - git version to install 55 | - `node['git']['url']` - URL to git tarball 56 | - `node['git']['checksum']` - tarball SHA256 checksum 57 | - `node['git']['use_pcre']` - if true, builds git with PCRE enabled 58 | 59 | ## Contributors 60 | 61 | This project exists thanks to all the people who [contribute.](https://opencollective.com/sous-chefs/contributors.svg?width=890&button=false) 62 | 63 | ### Backers 64 | 65 | Thank you to all our backers! 66 | 67 | ![https://opencollective.com/sous-chefs#backers](https://opencollective.com/sous-chefs/backers.svg?width=600&avatarHeight=40) 68 | 69 | ### Sponsors 70 | 71 | Support this project by becoming a sponsor. Your logo will show up here with a link to your website. 72 | 73 | ![https://opencollective.com/sous-chefs/sponsor/0/website](https://opencollective.com/sous-chefs/sponsor/0/avatar.svg?avatarHeight=100) 74 | ![https://opencollective.com/sous-chefs/sponsor/1/website](https://opencollective.com/sous-chefs/sponsor/1/avatar.svg?avatarHeight=100) 75 | ![https://opencollective.com/sous-chefs/sponsor/2/website](https://opencollective.com/sous-chefs/sponsor/2/avatar.svg?avatarHeight=100) 76 | ![https://opencollective.com/sous-chefs/sponsor/3/website](https://opencollective.com/sous-chefs/sponsor/3/avatar.svg?avatarHeight=100) 77 | ![https://opencollective.com/sous-chefs/sponsor/4/website](https://opencollective.com/sous-chefs/sponsor/4/avatar.svg?avatarHeight=100) 78 | ![https://opencollective.com/sous-chefs/sponsor/5/website](https://opencollective.com/sous-chefs/sponsor/5/avatar.svg?avatarHeight=100) 79 | ![https://opencollective.com/sous-chefs/sponsor/6/website](https://opencollective.com/sous-chefs/sponsor/6/avatar.svg?avatarHeight=100) 80 | ![https://opencollective.com/sous-chefs/sponsor/7/website](https://opencollective.com/sous-chefs/sponsor/7/avatar.svg?avatarHeight=100) 81 | ![https://opencollective.com/sous-chefs/sponsor/8/website](https://opencollective.com/sous-chefs/sponsor/8/avatar.svg?avatarHeight=100) 82 | ![https://opencollective.com/sous-chefs/sponsor/9/website](https://opencollective.com/sous-chefs/sponsor/9/avatar.svg?avatarHeight=100) 83 | -------------------------------------------------------------------------------- /TESTING.md: -------------------------------------------------------------------------------- 1 | # Testing 2 | 3 | Please refer to [the community cookbook documentation on testing](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/main/TESTING.MD). 4 | -------------------------------------------------------------------------------- /attributes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Jamie Winsor () 3 | # Cookbook:: git 4 | # Attributes:: default 5 | # 6 | # Copyright:: 2008-2019, Chef Software, Inc. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the 'License'); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an 'AS IS' BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | 20 | if platform_family?('windows') 21 | default['git']['version'] = '2.35.1' 22 | if node['kernel']['machine'] == 'x86_64' 23 | default['git']['architecture'] = '64' 24 | default['git']['checksum'] = '5d66948e7ada0ab184b2745fdf6e11843443a97655891c3c6268b5985b88bf4f' 25 | else 26 | default['git']['architecture'] = '32' 27 | default['git']['checksum'] = '5e45b1226b106dd241de0be0b350052afe53bd61dce80ac6044600dc85fbfa0b' 28 | end 29 | default['git']['url'] = 'https://github.com/git-for-windows/git/releases/download/v%{version}.windows.1/Git-%{version}-%{architecture}-bit.exe' 30 | default['git']['display_name'] = "Git version #{node['git']['version']}" 31 | else 32 | default['git']['prefix'] = '/usr/local' 33 | default['git']['version'] = '2.17.1' 34 | default['git']['url'] = 'https://nodeload.github.com/git/git/tar.gz/v%{version}' 35 | default['git']['checksum'] = '690f12cc5691e5adaf2dd390eae6f5acce68ae0d9bd9403814f8a1433833f02a' 36 | default['git']['use_pcre'] = false 37 | end 38 | 39 | default['git']['server']['base_path'] = '/srv/git' 40 | default['git']['server']['export_all'] = true 41 | -------------------------------------------------------------------------------- /chefignore: -------------------------------------------------------------------------------- 1 | # Put files/directories that should be ignored in this file when uploading 2 | # to a Chef Infra Server or Supermarket. 3 | # Lines that start with '# ' are comments. 4 | 5 | # OS generated files # 6 | ###################### 7 | .DS_Store 8 | ehthumbs.db 9 | Icon? 10 | nohup.out 11 | Thumbs.db 12 | .envrc 13 | 14 | # EDITORS # 15 | ########### 16 | .#* 17 | .project 18 | .settings 19 | *_flymake 20 | *_flymake.* 21 | *.bak 22 | *.sw[a-z] 23 | *.tmproj 24 | *~ 25 | \#* 26 | REVISION 27 | TAGS* 28 | tmtags 29 | .vscode 30 | .editorconfig 31 | 32 | ## COMPILED ## 33 | ############## 34 | *.class 35 | *.com 36 | *.dll 37 | *.exe 38 | *.o 39 | *.pyc 40 | *.so 41 | */rdoc/ 42 | a.out 43 | mkmf.log 44 | 45 | # Testing # 46 | ########### 47 | .circleci/* 48 | .codeclimate.yml 49 | .delivery/* 50 | .foodcritic 51 | .kitchen* 52 | .mdlrc 53 | .overcommit.yml 54 | .rspec 55 | .rubocop.yml 56 | .travis.yml 57 | .watchr 58 | .yamllint 59 | azure-pipelines.yml 60 | Dangerfile 61 | examples/* 62 | features/* 63 | Guardfile 64 | kitchen*.yml 65 | mlc_config.json 66 | Procfile 67 | Rakefile 68 | spec/* 69 | test/* 70 | 71 | # SCM # 72 | ####### 73 | .git 74 | .gitattributes 75 | .gitconfig 76 | .github/* 77 | .gitignore 78 | .gitkeep 79 | .gitmodules 80 | .svn 81 | */.bzr/* 82 | */.git 83 | */.hg/* 84 | */.svn/* 85 | 86 | # Berkshelf # 87 | ############# 88 | Berksfile 89 | Berksfile.lock 90 | cookbooks/* 91 | tmp 92 | 93 | # Bundler # 94 | ########### 95 | vendor/* 96 | Gemfile 97 | Gemfile.lock 98 | 99 | # Policyfile # 100 | ############## 101 | Policyfile.rb 102 | Policyfile.lock.json 103 | 104 | # Documentation # 105 | ############# 106 | CODE_OF_CONDUCT* 107 | CONTRIBUTING* 108 | documentation/* 109 | TESTING* 110 | UPGRADING* 111 | 112 | # Vagrant # 113 | ########### 114 | .vagrant 115 | Vagrantfile 116 | -------------------------------------------------------------------------------- /documentation/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sous-chefs/git/ca802a9cf53d620bd5d4ead0b055ff301b1a7587/documentation/.gitkeep -------------------------------------------------------------------------------- /documentation/git_client.md: -------------------------------------------------------------------------------- 1 | # git_client 2 | 3 | The `git_client` resource manages the installation of a Git client on a machine. 4 | 5 | `Note`: on macOS systems homebrew must first be installed on the system before running this resource. Prior to version 9.0 of this cookbook homebrew was automatically installed. 6 | 7 | ## Example 8 | 9 | ```ruby 10 | git_client 'default' 11 | ``` 12 | 13 | ## Example of source install 14 | 15 | ```ruby 16 | git_client 'source' do 17 | source_version '2.14.2' 18 | source_checksum 'a03a12331d4f9b0f71733db9f47e1232d4ddce00e7f2a6e20f6ec9a19ce5ff61' 19 | action :install_from_source 20 | end 21 | ``` 22 | -------------------------------------------------------------------------------- /documentation/git_config.md: -------------------------------------------------------------------------------- 1 | # git_config 2 | 3 | The `git_config` resource manages the configuration of Git client on a machine. 4 | 5 | ## Example 6 | 7 | ```ruby 8 | git_config 'url.https://github.com/.insteadOf' do 9 | value 'git://github.com/' 10 | scope 'system' 11 | options '--add' 12 | end 13 | ``` 14 | 15 | ## Properties 16 | 17 | Currently, there are distinct sets of resource properties, used by the providers for source, package, macos, and windows. 18 | 19 | ### used by Linux provider 20 | 21 | - `package_name` - Package name to install on Linux machines. Defaults to a calculated value based on platform. 22 | - `package_version` - Defaults to nil. 23 | - `package_action` - Defaults to `:install` 24 | 25 | ### used by Linux source install 26 | 27 | - `source_prefix` - Defaults to '/usr/local' 28 | - `source_url` - Defaults to a calculated URL based on source_version 29 | - `source_version` - Defaults to 2.8.1 30 | - `source_use_pcre` - configure option for build. Defaults to false 31 | - `source_checksum` - Defaults to a known value for the 2.8.1 source tarball 32 | 33 | ### used by the Windows provider 34 | 35 | - `windows_display_name` - Windows display name 36 | - `windows_package_url` - Defaults to the Internet 37 | - `windows_package_checksum` - Defaults to the value for 2.8.1 38 | -------------------------------------------------------------------------------- /kitchen.dokken.yml: -------------------------------------------------------------------------------- 1 | driver: 2 | name: dokken 3 | privileged: true 4 | chef_version: <%= ENV['CHEF_VERSION'] || 'current' %> 5 | 6 | transport: { name: dokken } 7 | provisioner: { name: dokken } 8 | 9 | platforms: 10 | - name: almalinux-8 11 | driver: 12 | image: dokken/almalinux-8 13 | pid_one_command: /usr/lib/systemd/systemd 14 | 15 | - name: almalinux-9 16 | driver: 17 | image: dokken/almalinux-9 18 | pid_one_command: /usr/lib/systemd/systemd 19 | 20 | - name: almalinux-10 21 | driver: 22 | image: dokken/almalinux-10 23 | pid_one_command: /usr/lib/systemd/systemd 24 | 25 | - name: amazonlinux-2023 26 | driver: 27 | image: dokken/amazonlinux-2023 28 | pid_one_command: /usr/lib/systemd/systemd 29 | 30 | - name: centos-stream-9 31 | driver: 32 | image: dokken/centos-stream-9 33 | pid_one_command: /usr/lib/systemd/systemd 34 | 35 | - name: centos-stream-10 36 | driver: 37 | image: dokken/centos-stream-10 38 | pid_one_command: /usr/lib/systemd/systemd 39 | 40 | - name: debian-11 41 | driver: 42 | image: dokken/debian-11 43 | pid_one_command: /bin/systemd 44 | 45 | - name: debian-12 46 | driver: 47 | image: dokken/debian-12 48 | pid_one_command: /bin/systemd 49 | 50 | - name: fedora-latest 51 | driver: 52 | image: dokken/fedora-latest 53 | pid_one_command: /usr/lib/systemd/systemd 54 | 55 | - name: opensuse-leap-15 56 | driver: 57 | image: dokken/opensuse-leap-15 58 | pid_one_command: /usr/lib/systemd/systemd 59 | 60 | - name: oraclelinux-8 61 | driver: 62 | image: dokken/oraclelinux-8 63 | pid_one_command: /usr/lib/systemd/systemd 64 | 65 | - name: oraclelinux-9 66 | driver: 67 | image: dokken/oraclelinux-9 68 | pid_one_command: /usr/lib/systemd/systemd 69 | 70 | - name: rockylinux-8 71 | driver: 72 | image: dokken/rockylinux-8 73 | pid_one_command: /usr/lib/systemd/systemd 74 | 75 | - name: rockylinux-9 76 | driver: 77 | image: dokken/rockylinux-9 78 | pid_one_command: /usr/lib/systemd/systemd 79 | 80 | - name: ubuntu-20.04 81 | driver: 82 | image: dokken/ubuntu-20.04 83 | pid_one_command: /bin/systemd 84 | 85 | - name: ubuntu-22.04 86 | driver: 87 | image: dokken/ubuntu-22.04 88 | pid_one_command: /bin/systemd 89 | 90 | - name: ubuntu-24.04 91 | driver: 92 | image: dokken/ubuntu-24.04 93 | pid_one_command: /bin/systemd 94 | -------------------------------------------------------------------------------- /kitchen.exec.yml: -------------------------------------------------------------------------------- 1 | --- 2 | driver: { name: exec } 3 | transport: { name: exec } 4 | 5 | platforms: 6 | - name: macos-latest 7 | - name: windows-latest 8 | -------------------------------------------------------------------------------- /kitchen.global.yml: -------------------------------------------------------------------------------- 1 | --- 2 | provisioner: 3 | name: chef_infra 4 | product_name: chef 5 | product_version: <%= ENV['CHEF_VERSION'] || 'latest' %> 6 | channel: stable 7 | install_strategy: once 8 | chef_license: accept 9 | enforce_idempotency: <%= ENV['ENFORCE_IDEMPOTENCY'] || true %> 10 | multiple_converge: <%= ENV['MULTIPLE_CONVERGE'] || 2 %> 11 | deprecations_as_errors: true 12 | log_level: <%= ENV['CHEF_LOG_LEVEL'] || 'auto' %> 13 | 14 | verifier: 15 | name: inspec 16 | 17 | platforms: 18 | - name: almalinux-8 19 | - name: almalinux-9 20 | - name: amazonlinux-2023 21 | - name: centos-stream-9 22 | - name: debian-11 23 | - name: debian-12 24 | - name: fedora-latest 25 | - name: opensuse-leap-15 26 | - name: oraclelinux-8 27 | - name: oraclelinux-9 28 | - name: rockylinux-8 29 | - name: rockylinux-9 30 | - name: ubuntu-20.04 31 | - name: ubuntu-22.04 32 | - name: ubuntu-24.04 33 | -------------------------------------------------------------------------------- /kitchen.yml: -------------------------------------------------------------------------------- 1 | --- 2 | driver: 3 | name: vagrant 4 | gui: false 5 | 6 | provisioner: 7 | name: chef_infra 8 | product_name: <%= ENV['CHEF_PRODUCT_NAME'] || 'chef' %> 9 | enforce_idempotency: true 10 | multiple_converge: 2 11 | deprecations_as_errors: true 12 | chef_license: accept-no-persist 13 | 14 | verifier: 15 | name: inspec 16 | 17 | platforms: 18 | - name: amazonlinux-2 19 | - name: centos-7 20 | - name: centos-stream-8 21 | - name: debian-10 22 | - name: debian-11 23 | - name: freebsd-13 24 | - name: fedora-latest 25 | - name: opensuse-leap-15 26 | - name: ubuntu-18.04 27 | - name: ubuntu-20.04 28 | - name: windows-2012r2 29 | driver: 30 | box: tas50/windows_2012r2 31 | customize: 32 | cpus: 2 33 | memory: 4096 34 | transport: 35 | name: winrm 36 | elevated: true 37 | provisioner: 38 | enforce_idempotency: false 39 | multiple_converge: 1 40 | - name: windows-2016 41 | driver: 42 | box: tas50/windows_2016 43 | customize: 44 | cpus: 2 45 | memory: 4096 46 | transport: 47 | name: winrm 48 | elevated: true 49 | provisioner: 50 | enforce_idempotency: false 51 | multiple_converge: 1 52 | - name: windows-2019 53 | driver: 54 | box: tas50/windows_2019 55 | customize: 56 | cpus: 2 57 | memory: 4096 58 | transport: 59 | name: winrm 60 | elevated: true 61 | provisioner: 62 | enforce_idempotency: false 63 | multiple_converge: 1 64 | - name: macos-10.15 65 | run_list: homebrew::default 66 | driver: 67 | box: tas50/macos_10.15 68 | 69 | suites: 70 | - name: resources 71 | run_list: 72 | - recipe[test::default] 73 | - name: source 74 | run_list: 75 | - recipe[test::source] 76 | excludes: 77 | - windows-2012r2 78 | - windows-2016 79 | - windows-2019 80 | - macos-10.15 81 | -------------------------------------------------------------------------------- /libraries/helpers.rb: -------------------------------------------------------------------------------- 1 | module GitCookbook 2 | module Helpers 3 | # linux packages default to distro offering 4 | def parsed_package_name 5 | return new_resource.package_name if new_resource.package_name 6 | return 'developer/versioning/git' if platform?('omnios') 7 | return 'scmgit' if platform?('smartos') 8 | 'git' 9 | end 10 | 11 | def parsed_package_version 12 | return new_resource.package_version if new_resource.package_version 13 | end 14 | 15 | # source 16 | def parsed_source_url 17 | return new_resource.source_url if new_resource.source_url 18 | "https://nodeload.github.com/git/git/tar.gz/v#{new_resource.source_version}" 19 | end 20 | 21 | def parsed_source_checksum 22 | return new_resource.source_checksum if new_resource.source_checksum 23 | '690f12cc5691e5adaf2dd390eae6f5acce68ae0d9bd9403814f8a1433833f02a' # 2.17.1 tarball 24 | end 25 | 26 | # windows 27 | def parsed_windows_display_name 28 | return new_resource.windows_display_name if new_resource.windows_display_name 29 | "Git version #{parsed_windows_package_version}" 30 | end 31 | 32 | def parsed_windows_package_version 33 | return new_resource.windows_package_version if new_resource.windows_package_version 34 | '2.39.2' 35 | end 36 | 37 | def parsed_windows_package_url 38 | return new_resource.windows_package_url if new_resource.windows_package_url 39 | if node['kernel']['machine'] == 'x86_64' 40 | "https://github.com/git-for-windows/git/releases/download/v#{parsed_windows_package_version}.windows.1/Git-#{parsed_windows_package_version}-64-bit.exe" 41 | else 42 | "https://github.com/git-for-windows/git/releases/download/v#{parsed_windows_package_version}.windows.1/Git-#{parsed_windows_package_version}-32-bit.exe" 43 | end 44 | end 45 | 46 | def parsed_windows_package_checksum 47 | return new_resource.windows_package_checksum if new_resource.windows_package_checksum 48 | if node['kernel']['machine'] == 'x86_64' 49 | 'D7608FBD854B3689102FF48B03C8CC77B35138F9F7350D134306DA0BA5751464' 50 | else 51 | 'ADDF55B0A57F38A7950B3AD37CE5C76752202E6818D9F8995B477496B71FB757' 52 | end 53 | end 54 | end 55 | end 56 | -------------------------------------------------------------------------------- /metadata.rb: -------------------------------------------------------------------------------- 1 | name 'git' 2 | maintainer 'Sous Chefs' 3 | maintainer_email 'help@sous-chefs.org' 4 | license 'Apache-2.0' 5 | description 'Installs git and/or sets up a Git server daemon' 6 | version '12.1.7' 7 | source_url 'https://github.com/sous-chefs/git' 8 | issues_url 'https://github.com/sous-chefs/git/issues' 9 | chef_version '>= 15.3' 10 | 11 | depends 'ark' 12 | 13 | supports 'amazon' 14 | supports 'centos' 15 | supports 'debian' 16 | supports 'fedora' 17 | supports 'freebsd' 18 | supports 'mac_os_x' 19 | supports 'omnios' 20 | supports 'opensuseleap' 21 | supports 'oracle' 22 | supports 'redhat' 23 | supports 'scientific' 24 | supports 'smartos' 25 | supports 'suse' 26 | supports 'ubuntu' 27 | supports 'windows' 28 | -------------------------------------------------------------------------------- /recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: git 3 | # Recipe:: default 4 | # 5 | # Copyright:: 2008-2019, Chef Software, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | include_recipe 'git::package' 20 | -------------------------------------------------------------------------------- /recipes/package.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: git 3 | # Recipe:: package 4 | # 5 | # Copyright:: 2008-2019, Chef Software, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | git_client 'default' 20 | -------------------------------------------------------------------------------- /recipes/source.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: git 3 | # Recipe:: source 4 | # 5 | # Copyright:: 2012-2016, Brian Flad, Fletcher Nichol 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | # drive version from node attributes 20 | git_client 'default' do 21 | source_checksum node['git']['checksum'] 22 | source_prefix node['git']['prefix'] 23 | source_url format(node['git']['url'], version: node['git']['version']) 24 | source_use_pcre node['git']['use_pcre'] 25 | source_version node['git']['version'] 26 | action :install_from_source 27 | end 28 | -------------------------------------------------------------------------------- /recipes/windows.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: git 3 | # Recipe:: windows 4 | # 5 | # Copyright:: 2008-2019, Chef Software, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | git_client 'default' do 20 | windows_display_name node['git']['display_name'] 21 | windows_package_url format(node['git']['url'], version: node['git']['version'], architecture: node['git']['architecture']) 22 | windows_package_checksum node['git']['checksum'] 23 | end 24 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": ["config:base"], 4 | "packageRules": [ 5 | { 6 | "groupName": "Actions", 7 | "matchUpdateTypes": ["minor", "patch", "pin"], 8 | "automerge": true, 9 | "addLabels": ["Release: Patch", "Skip: Announcements"] 10 | }, 11 | { 12 | "groupName": "Actions", 13 | "matchUpdateTypes": ["major"], 14 | "automerge": false, 15 | "addLabels": ["Release: Patch", "Skip: Announcements"] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /resources/client_linux.rb: -------------------------------------------------------------------------------- 1 | unified_mode true 2 | 3 | provides :git_client, os: 'linux' 4 | 5 | # :install 6 | property :package_name, String 7 | property :package_version, String 8 | property :package_action, Symbol, default: :install 9 | 10 | # :install_from_source 11 | property :source_checksum, String 12 | property :source_prefix, String, default: '/usr/local' 13 | property :source_url, String 14 | property :source_use_pcre, [true, false], default: false 15 | property :source_version, String 16 | 17 | action_class do 18 | include GitCookbook::Helpers 19 | end 20 | 21 | action :install do 22 | # Software installation 23 | package "#{new_resource.name} :create #{parsed_package_name}" do 24 | package_name parsed_package_name 25 | version parsed_package_version 26 | action new_resource.package_action 27 | end 28 | end 29 | 30 | action :install_from_source do 31 | raise "source install is not supported on #{node['platform']}" unless platform_family?('rhel', 'suse', 'fedora', 'debian', 'amazon') 32 | 33 | build_essential 'install compilation tools for git' 34 | 35 | case node['platform_family'] 36 | when 'rhel', 'fedora', 'amazon' 37 | pkgs = %w(tar expat-devel gettext-devel libcurl-devel openssl-devel perl-ExtUtils-MakeMaker zlib-devel) 38 | pkgs << 'pcre-devel' if new_resource.source_use_pcre 39 | when 'debian' 40 | pkgs = %w(libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev) 41 | pkgs << 'libpcre3-dev' if new_resource.source_use_pcre 42 | when 'suse' 43 | pkgs = %w(tar libcurl-devel libexpat-devel gettext-tools zlib-devel libopenssl-devel) 44 | pkgs << 'libpcre2-devel' if new_resource.source_use_pcre 45 | end 46 | 47 | package pkgs 48 | 49 | ark 'git' do 50 | url parsed_source_url 51 | extension 'tar.gz' 52 | version new_resource.source_version 53 | checksum parsed_source_checksum 54 | make_opts ["prefix=#{new_resource.source_prefix}", ('USE_LIBPCRE=1' if new_resource.source_use_pcre)] 55 | action :install_with_make 56 | end 57 | end 58 | -------------------------------------------------------------------------------- /resources/client_osx.rb: -------------------------------------------------------------------------------- 1 | unified_mode true 2 | 3 | provides :git_client, platform: 'mac_os_x' 4 | 5 | action :install do 6 | package 'git' do 7 | options '--override' 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /resources/client_windows.rb: -------------------------------------------------------------------------------- 1 | unified_mode true 2 | 3 | provides :git_client, os: 'windows' 4 | 5 | property :windows_display_name, String 6 | property :windows_package_url, String 7 | property :windows_package_checksum, String 8 | property :windows_package_version, String 9 | 10 | action_class do 11 | include GitCookbook::Helpers 12 | end 13 | 14 | action :install do 15 | windows_package parsed_windows_display_name do 16 | source parsed_windows_package_url 17 | checksum parsed_windows_package_checksum 18 | version parsed_windows_package_version 19 | installer_type :inno 20 | end 21 | 22 | # Git is installed to Program Files (x86) on 64-bit machines and 23 | # 'Program Files' on 32-bit machines 24 | PROGRAM_FILES = if node['git']['architecture'] == '32' 25 | ENV['ProgramFiles(x86)'] || ENV['ProgramFiles'] 26 | else 27 | ENV['ProgramW6432'] || ENV['ProgramFiles'] 28 | end 29 | GIT_PATH = "#{PROGRAM_FILES}\\Git\\Cmd".freeze 30 | 31 | # COOK-3482 - windows_path resource doesn't change the current process 32 | # environment variables. Therefore, git won't actually be on the PATH 33 | # until the next chef-client run 34 | ruby_block 'Add Git Path' do 35 | block do 36 | ENV['PATH'] += ";#{GIT_PATH}" 37 | end 38 | not_if { ENV['PATH'] =~ /GIT_PATH/ } 39 | action :nothing 40 | end 41 | 42 | windows_path GIT_PATH do 43 | notifies :run, 'ruby_block[Add Git Path]', :immediately 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /resources/config.rb: -------------------------------------------------------------------------------- 1 | unified_mode true 2 | 3 | property :key, String, name_property: true 4 | property :value, String 5 | property :scope, String, equal_to: %w(local global system file), default: 'global', desired_state: false 6 | property :config_file, String, desired_state: false 7 | property :path, String, desired_state: false 8 | property :user, String, desired_state: false 9 | property :group, String, desired_state: false 10 | property :password, String, desired_state: false, sensitive: true 11 | property :options, String, desired_state: false 12 | 13 | load_current_value do 14 | begin 15 | home_dir = ::Dir.home(user) 16 | rescue 17 | value nil 18 | end 19 | 20 | cmd_env = user ? { 'USER' => user, 'HOME' => home_dir } : nil 21 | config_vals = Mixlib::ShellOut.new( 22 | "git config --get --#{scope} #{config_file} #{key}", 23 | user: user, 24 | group: group, 25 | password: password, 26 | cwd: path, 27 | env: cmd_env 28 | ) 29 | config_vals.run_command 30 | if config_vals.stdout.empty? 31 | value nil 32 | else 33 | value config_vals.stdout.chomp 34 | end 35 | end 36 | 37 | action :set do 38 | converge_if_changed do 39 | execute "#{config_cmd} #{new_resource.key} \"#{new_resource.value}\" #{new_resource.options}".rstrip do 40 | cwd new_resource.path 41 | user new_resource.user 42 | group new_resource.group 43 | password new_resource.password 44 | environment cmd_env 45 | end 46 | end 47 | end 48 | 49 | action_class do 50 | def config_cmd 51 | "git config --#{new_resource.scope} #{new_resource.config_file}" 52 | end 53 | 54 | def cmd_env 55 | new_resource.user ? { 'USER' => new_resource.user, 'HOME' => ::Dir.home(new_resource.user) } : nil 56 | end 57 | end 58 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'chefspec' 2 | require 'chefspec/berkshelf' 3 | 4 | RSpec.configure do |config| 5 | config.formatter = :documentation # Use the specified formatter 6 | config.color = true 7 | config.log_level = :fatal # ignore warnings 8 | config.alias_example_group_to :describe_recipe, type: :recipe 9 | config.alias_example_group_to :describe_resource, type: :resource 10 | config.alias_example_group_to :describe_attribute, type: :attribute 11 | 12 | config.filter_run :focus 13 | config.run_all_when_everything_filtered = true 14 | 15 | Kernel.srand config.seed 16 | config.order = :random 17 | 18 | config.default_formatter = 'doc' if config.files_to_run.one? 19 | 20 | config.expect_with :rspec do |expectations| 21 | expectations.syntax = :expect 22 | end 23 | 24 | config.mock_with :rspec do |mocks| 25 | mocks.syntax = :expect 26 | mocks.verify_partial_doubles = true 27 | end 28 | end 29 | 30 | RSpec.shared_context 'recipe tests', type: :recipe do 31 | let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '16.04').converge(described_recipe) } 32 | end 33 | -------------------------------------------------------------------------------- /spec/unit/recipes/default_spec.rb: -------------------------------------------------------------------------------- 1 | require_relative '../../spec_helper' 2 | 3 | describe 'git::default' do 4 | context 'on windows' do 5 | let(:chef_run) do 6 | ChefSpec::ServerRunner.new( 7 | platform: 'windows', 8 | version: '10' 9 | ).converge(described_recipe) 10 | end 11 | 12 | it { is_expected.to install_git_client('default') } 13 | end 14 | 15 | context 'on linux' do 16 | platform 'ubuntu' 17 | 18 | it { is_expected.to install_git_client('default') } 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /spec/unit/recipes/source_spec.rb: -------------------------------------------------------------------------------- 1 | require_relative '../../spec_helper' 2 | 3 | describe 'git::source' do 4 | platform 'ubuntu' 5 | 6 | step_into :git_client 7 | 8 | before do 9 | stub_command(%r{test -f /tmp/.+/git-2.17.1.tar.gz}) 10 | stub_command('git --version | grep 2.17.1') 11 | stub_command('/usr/local/bin/git --version | grep 2.17.1') 12 | end 13 | 14 | it do 15 | is_expected.to install_from_source_git_client('default').with( 16 | source_checksum: '690f12cc5691e5adaf2dd390eae6f5acce68ae0d9bd9403814f8a1433833f02a', 17 | source_prefix: '/usr/local', 18 | source_url: 'https://nodeload.github.com/git/git/tar.gz/v2.17.1', 19 | source_use_pcre: false, 20 | source_version: '2.17.1' 21 | ) 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /spec/unit/recipes/windows_spec.rb: -------------------------------------------------------------------------------- 1 | require_relative '../../spec_helper' 2 | 3 | describe_recipe 'git::windows' do 4 | let(:chef_run) do 5 | ChefSpec::ServerRunner.new( 6 | platform: 'windows', 7 | version: '10' 8 | ).converge(described_recipe) 9 | end 10 | 11 | it do 12 | expect(chef_run).to install_git_client('default').with( 13 | windows_display_name: 'Git version 2.35.1', 14 | windows_package_url: 'https://github.com/git-for-windows/git/releases/download/v2.35.1.windows.1/Git-2.35.1-64-bit.exe', 15 | windows_package_checksum: '5d66948e7ada0ab184b2745fdf6e11843443a97655891c3c6268b5985b88bf4f' 16 | ) 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /templates/git-xinetd.d.erb: -------------------------------------------------------------------------------- 1 | service git 2 | { 3 | disable = no 4 | socket_type = stream 5 | wait = no 6 | user = nobody 7 | server = <%= @git_daemon_binary %> 8 | server_args = --base-path=<%= node["git"]["server"]["base_path"] %> <%= node['git']['server']['export_all'] ? '--export-all' : nil %> --syslog --inetd --verbose 9 | log_on_failure += USERID 10 | } 11 | -------------------------------------------------------------------------------- /test/fixtures/cookbooks/test/metadata.rb: -------------------------------------------------------------------------------- 1 | name 'test' 2 | version '0.1.0' 3 | 4 | depends 'git' 5 | -------------------------------------------------------------------------------- /test/fixtures/cookbooks/test/recipes/default.rb: -------------------------------------------------------------------------------- 1 | apt_update 2 | 3 | git_client 'install it' 4 | 5 | home_dir = 6 | if windows? 7 | 'C:\temp' 8 | elsif macos? 9 | '/Users/random' 10 | else 11 | '/home/random' 12 | end 13 | 14 | user 'random' do 15 | manage_home true 16 | home home_dir 17 | end unless windows? 18 | 19 | directory 'C:\temp' if windows? 20 | 21 | git_config 'add name to random' do 22 | user 'random' unless windows? 23 | scope 'global' 24 | key 'user.name' 25 | value 'John Doe global' 26 | end 27 | 28 | git "#{home_dir}/git_repo" do 29 | repository 'https://github.com/chef/chef-repo.git' 30 | user 'random' unless windows? 31 | end 32 | 33 | git_config 'change local path' do 34 | user 'random' unless windows? 35 | scope 'local' 36 | key 'user.name' 37 | value 'John Doe local' 38 | path "#{home_dir}/git_repo" 39 | end 40 | 41 | git_config 'change system config' do 42 | scope 'system' 43 | key 'user.name' 44 | value 'John Doe system' 45 | end 46 | 47 | git_config 'url.https://github.com/.insteadOf' do 48 | value 'git://github.com/' 49 | scope 'system' 50 | options '--add' 51 | end 52 | 53 | git_config 'user.signingkey' do 54 | value 'FA2D8E280A6DD5' 55 | scope 'file' 56 | config_file '~/.gitconfig.key' 57 | end 58 | -------------------------------------------------------------------------------- /test/fixtures/cookbooks/test/recipes/server.rb: -------------------------------------------------------------------------------- 1 | apt_update 2 | 3 | include_recipe 'git::server' 4 | -------------------------------------------------------------------------------- /test/fixtures/cookbooks/test/recipes/source.rb: -------------------------------------------------------------------------------- 1 | apt_update 2 | 3 | include_recipe 'git::source' 4 | -------------------------------------------------------------------------------- /test/integration/resources/git_installed_spec.rb: -------------------------------------------------------------------------------- 1 | # rubocop:disable Chef/Deprecations/ResourceWithoutUnifiedTrue 2 | home_dir = 3 | if os.family == 'windows' 4 | if user('vagrant') 5 | 'C:/Users/vagrant' 6 | else 7 | 'C:/Users/RUNNER~1' 8 | end 9 | elsif os.family == 'darwin' 10 | '/Users/random' 11 | else 12 | '/home/random' 13 | end 14 | 15 | repo_dir = 16 | if os.family == 'windows' 17 | 'C:/temp' 18 | else 19 | home_dir 20 | end 21 | 22 | etc_dir = 23 | if os.family == 'windows' 24 | 'C:/Program Files/Git/etc' 25 | elsif os.family == 'darwin' 26 | '/usr/local/etc' 27 | else 28 | '/etc' 29 | end 30 | 31 | describe command('git --version') do 32 | its('exit_status') { should eq 0 } 33 | its('stdout') { should match /git version/ } 34 | end 35 | 36 | describe ini("#{home_dir}/.gitconfig") do 37 | its(%w(user name)) { should eq 'John Doe global' } 38 | end 39 | 40 | describe ini("#{repo_dir}/git_repo/.git/config") do 41 | its(%w(user name)) { should eq 'John Doe local' } 42 | end 43 | 44 | describe ini("#{etc_dir}/gitconfig") do 45 | its(%w(user name)) { should eq 'John Doe system' } 46 | its(['url "https://github.com/"', 'insteadOf']) { should eq 'git://github.com/' } 47 | end 48 | 49 | describe ini('/root/.gitconfig.key') do 50 | its(%w(user signingkey)) { should eq 'FA2D8E280A6DD5' } 51 | end 52 | -------------------------------------------------------------------------------- /test/integration/server/git_daemon_spec.rb: -------------------------------------------------------------------------------- 1 | describe port(9418) do 2 | it { should be_listening } 3 | its('protocols') { should eq ['tcp'] } 4 | end 5 | -------------------------------------------------------------------------------- /test/integration/source/git_installed_spec.rb: -------------------------------------------------------------------------------- 1 | describe command('/usr/local/bin/git --version') do 2 | its('exit_status') { should eq 0 } 3 | its('stdout') { should match /git version/ } 4 | end 5 | --------------------------------------------------------------------------------