-
Notifications
You must be signed in to change notification settings - Fork 534
added support for quarantine directory #887
Conversation
I'm looking at why the travis build has failed, and I'm not sure why my changes impact this
Any help would be appreciated |
So the test error is because I am changing the output in some cases to |
@noxora Thanks for the pull request! It would be good to mention quarantine environment somewhere in the code / comments, with a link to https://git-scm.com/docs/git-receive-pack#_quarantine_environment This way those of us who didn't heard about this before will not be confused ;) I still do not see how the whole thing would work to mimick a pre-receive hook. We would need to know more about that before merging this. For example:
|
@smola Thanks for the response, I should have been clearer This is not intended to mimic a pre-receive hook, it only enables the writing of one using this library. I started writing a hook using this library and when I went to run it, I found that go-git was not finding the object I wanted to compare with inside the quarantine directory. This pull request is intended to add support to look for a 'quarantine' directory containing objects so that a pre-receive hook created with this library can work with the incoming objects. As per your questions
|
@smola Without the environment variables described in Jeff King's response, I believe this is currently the best option available to support quarantine directories. If there are any changes you would like me to make, I would be happy to, but I would like to know if you would like to move forward with this pull request. If you would, please let me know if there is anything I can do to help with it |
@mcuadros I apologize if this bothers you, but I haven't heard back from anyone in quite some time. Would you be able to take a look at this? |
@noxora Will be great if you can cover the new functionality with some tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still curious about how you'll implement the full hook behaviour. This PR is good. I'm just proposing more fine-grained handling of errors.
storage/filesystem/dotgit/dotgit.go
Outdated
} | ||
|
||
// ObjectDelete removes the object file, if exists | ||
func (d *DotGit) ObjectDelete(h plumbing.Hash) error { | ||
return d.fs.Remove(d.objectPath(h)) | ||
err1 := d.fs.Remove(d.objectPath(h)) | ||
if err1 != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only fallback to incoming object if os.IsNotExist(err1)
.
storage/filesystem/dotgit/dotgit.go
Outdated
} | ||
|
||
// ObjectStat returns a os.FileInfo pointing the object file, if exists | ||
func (d *DotGit) ObjectStat(h plumbing.Hash) (os.FileInfo, error) { | ||
return d.fs.Stat(d.objectPath(h)) | ||
obj1, err1 := d.fs.Stat(d.objectPath(h)) | ||
if err1 != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use os.IsNotExist
storage/filesystem/dotgit/dotgit.go
Outdated
// Object returns a fs.File pointing the object file, if exists | ||
func (d *DotGit) Object(h plumbing.Hash) (billy.File, error) { | ||
return d.fs.Open(d.objectPath(h)) | ||
obj1, err1 := d.fs.Open(d.objectPath(h)) | ||
if err1 != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use os.IsNotExist
Commits squashed and signed, added tests, but I have no idea why one of the three failed in appveyor, I will be looking into this, but the tests are very similar.
|
2085391
to
65052ac
Compare
Alright, so for some reason All three of these tests pass on my macbook, so I am not sure why it is failing there I would also like to clarify how this change helps with a git-hook. By allowing the library to see a quarantined directory, one could write a git pre-receive hook using this library to do something like diff the HEAD with the incoming changes and perform some checks on any added/changed logic. It is not part of triggering a hook to be run, but I would be happy to add that later in a different PR |
// incomingDirPath := fs.Join("objects", "incoming-123456") | ||
// incomingFilePath := fs.Join(incomingDirPath, incomingHash[0:2], incomingHash[2:40]) | ||
// fs.MkdirAll(incomingDirPath, os.FileMode(0755)) | ||
// fs.Create(incomingFilePath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You did not create the incomingHash[0:2]
directory before creating incomingFilePath
.
Also assert fs.MkdirAll
and fs.Create
do not return errors.
Maybe the problem is related to that. Or maybe something related to os.IsNotExist
on Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried those changes, and it also failed so I'm not exactly sure what's going on.
The changes are included, but commented out
Signed-off-by: noxora <[email protected]> trying a possible fix to the delete test Signed-off-by: noxora <[email protected]> still trying to fix this test Signed-off-by: noxora <[email protected]> fixes did not work, seems to be a windows env problem Signed-off-by: noxora <[email protected]>
Signed-off-by: Santiago M. Mola <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the failing test.
This is a part of issue #886
I have tested this on my local installation and it has allowed me to create a "commitObject" from an object sitting in a quarantine directory as per the git-receive-pack
This code might be put in the wrong place, or implemented differently than you all would like, so feel free to move/alter it.
The idea of it is to check to see if the file whose path you're returning is actually there, and if not to see if there is an
incoming-XXXXXXX
directory and look for the file in there