Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • G gitlabhq1
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • gpt
  • large_projects
  • gitlabhq1
  • Merge requests
  • !9044

Merged
Created Mar 27, 2015 by Administrator@rootOwner

Define GIT_TEMPLATE_DIR environment variable in TestEnv

  • Overview 2
  • Commits 1
  • Changes 1

Created by: rspeicher

See http://schacon.github.io/git/git-init.html#_template_directory

Without this variable, any global git hooks a developer might have in ~/.git_template would be linked in the .git/hooks folder for every test repository that gets checked out by TestEnv, and would cause certain specs to fail due to pre-existing hook files.

For example, using the dotfiles from thoughtbot, a spec run spits out errors like this:

Failures:

  1) Project find_with_namespace with namespace
     Failure/Error: @project = create(:project, name: 'gitlabhq', namespace: @group)
     Errno::EEXIST:
       File exists @ sys_fail2 - (/Users/tsigo/dotfiles/git_template/hooks/ctags, /Users/tsigo/Code/rails/gitlab-development-kit/gitlab/tmp/tests/repositories/gitlab/gitlabhq.git/./hooks/ctags)
     # ./spec/support/test_env.rb:95:in `copy_repo'
     # ./spec/factories/projects.rb:75:in `block (3 levels) in <top (required)>'
     # ./spec/models/project_spec.rb:156:in `block (4 levels) in <top (required)>'

  2) Project find_with_namespace with namespace
     Failure/Error: @project = create(:project, name: 'gitlabhq', namespace: @group)
     Errno::EEXIST:
       File exists @ sys_fail2 - (/Users/tsigo/dotfiles/git_template/hooks/ctags, /Users/tsigo/Code/rails/gitlab-development-kit/gitlab/tmp/tests/repositories/gitlab/gitlabhq.git/./hooks/ctags)
     # ./spec/support/test_env.rb:95:in `copy_repo'
     # ./spec/factories/projects.rb:75:in `block (3 levels) in <top (required)>'
     # ./spec/models/project_spec.rb:156:in `block (4 levels) in <top (required)>'

Finished in 6.86 seconds
67 examples, 2 failures

Failed examples:

rspec ./spec/models/project_spec.rb:159 # Project find_with_namespace with namespace
rspec ./spec/models/project_spec.rb:160 # Project find_with_namespace with namespace

The argument could be made that since it's the developer's setup that's breaking the tests, it's up to the developer to fix their setup, but this fix is simpler and I think it's valid because the purpose of TestEnv is to ensure a clean testing environment for the underlying Git operations.

Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: github/fork/rspeicher/rs-git-template-env