Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

object: fix Change.Files() method behavior (fix #317) #324

Merged
merged 2 commits into from
Apr 6, 2017
Merged

object: fix Change.Files() method behavior (fix #317) #324

merged 2 commits into from
Apr 6, 2017

Conversation

ajnavarro
Copy link
Contributor

@ajnavarro ajnavarro commented Apr 5, 2017

  • If 'from' or 'to' are tree entries that aren't files, Files() method will return nil instead of object not found error.
  • Added a test checking this using modules fixture.

@ajnavarro ajnavarro requested review from smola and alcortesm April 5, 2017 15:22
@codecov
Copy link

codecov bot commented Apr 5, 2017

Codecov Report

Merging #324 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #324      +/-   ##
==========================================
+ Coverage   77.35%   77.36%   +0.01%     
==========================================
  Files         117      117              
  Lines        8015     8019       +4     
==========================================
+ Hits         6200     6204       +4     
  Misses       1156     1156              
  Partials      659      659
Impacted Files Coverage Δ
plumbing/object/change.go 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 31a249d...fcfeefb. Read the comment docs.

@@ -61,6 +70,12 @@ func (c *Change) Files() (from, to *File, err error) {
return
}

func isInvalidFileMode(t TreeEntry) bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the FileMode methods: https://godoc.org/gopkg.in/src-d/go-git.v4/plumbing/filemode

I think that is this method can be replaced with a call to FileMode.IsRegular()

Copy link
Contributor Author

@ajnavarro ajnavarro Apr 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcuadros I think FileMode.IsRegular() doesn't cover all the cases, like executable files. Maybe @alcortesm could bring us some hints.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then you have IsFile. Why the symlink is being skip, is a regular file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Filemode.IsFile(), that's what @santi and me agreed when I answered #317.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alcortesm It's @smola ;-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, sorry!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. I was confused when we talked this morning.
@ajnavarro Symlinks can be returned by Files()

- If 'from' or 'to' are tree entries that aren't files, Files() method will return nil instead of object not found error.
- Added a test checking this using modules fixture.
@mcuadros mcuadros merged commit 8ede779 into src-d:master Apr 6, 2017
@ajnavarro ajnavarro deleted the fix/changes-file-for-non-files-no-error branch April 6, 2017 13:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants