Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"[git-rev-sync] no git repository found" when working with git --work-tree #44

Open
janwerkhoven opened this issue Oct 29, 2018 · 3 comments

Comments

@janwerkhoven
Copy link

A common pattern in production environments is to put a bare git repository (see repo/) outside the working directories (see releases/) so you can deploy with minimal disruption of the live release:

current -> symlink to releases/3
repo/
releases/1/
releases/2/
releases/3/
releases/3/package.json
releases/3/node_modules
releases/3/config/environment.js

Which deploys with a command like:

git --work-tree=/path/to/releases/3/ --git-dir=/path/to/repo/ checkout $branch -f

Running git.short() in the environment.js I keep getting this error:

[git-rev-sync] no git repository found

I tried:

git.short('/absolute/path/to/repo/');
git.short('../repo/');
git.short('../../repo/');
...

Whatever I try, can't seem to grab the git repository.

Any ideas?

@kurttheviking
Copy link
Owner

yeah this is a known issue; open to PRs with a reasonable approach on the best way to handle this

@janwerkhoven
Copy link
Author

Because work tree directories do not have a .git directory I don't believe we can make git-rev-sync discover the git directory.

Possible solutions:

  1. Allow the git directory to be passed as argument git.short('/path/to/repo/')
  2. Manually add a .git symlink to /path/to/repo/ the root of every work tree?

@septs
Copy link

septs commented Feb 18, 2020

https://github.com/NiceLabs/git-rev

import { Git }  from "@nice-labs/git-rev";
import * as path from "path";

const git = new Git(path.relative(process.cwd(), "../../repo"))

git.commitHash()

// equivalent form: git rev-parse HEAD
// working directory: path.relative(process.cwd(), "../../repo")

Can come and use my brand new implementation.

@janwerkhoven janwerkhoven changed the title "[git-rev-sync] no git repository found" when working directory is not git directory "[git-rev-sync] no git repository found" when working with git --work-tree Feb 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants