This repository was archived by the owner on Sep 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 534
repository: added cleanup for PlainClone. Fixes #741 #880
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
77f738c
repository: added cleanup for the PlainCloneContext(). [Fixes #741]
bjaroszewski 203a372
repository: added cleanup for the PlainCloneContext(). [Fixes #741]
bjaroszewski 5230acf
repository: added cleanup for the PlainCloneContext(). [Fixes #741]
bjaroszewski 520ddb5
Merge remote-tracking branch 'upstream/master'
bjaroszewski 4599a77
repository: added cleanup for the PlainCloneContext(). [Fixes #741]
bjaroszewski 6d3a9c3
repository: fixed typo in PlainCloneContext(). [Fixes #741]
bjaroszewski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -568,17 +568,55 @@ func (s *RepositorySuite) TestPlainClone(c *C) { | |
c.Assert(cfg.Branches["master"].Name, Equals, "master") | ||
} | ||
|
||
func (s *RepositorySuite) TestPlainCloneContext(c *C) { | ||
func (s *RepositorySuite) TestPlainCloneContextWithProperParameters(c *C) { | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
cancel() | ||
|
||
_, err := PlainCloneContext(ctx, c.MkDir(), false, &CloneOptions{ | ||
r, err := PlainCloneContext(ctx, c.MkDir(), false, &CloneOptions{ | ||
URL: s.GetBasicLocalRepositoryURL(), | ||
}) | ||
|
||
c.Assert(r, NotNill) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. still a typo here... you want NotNil, not NotNill |
||
c.Assert(err, NotNil) | ||
} | ||
|
||
func (s *RepositorySuite) TestPlainCloneContextWithIncorrectRepo(c *C) { | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
cancel() | ||
|
||
tmpDir := c.MkDir() | ||
repoDir := filepath.Join(tmpDir, "repoDir") | ||
r, err := PlainCloneContext(ctx, repoDir, false, &CloneOptions{ | ||
URL: "incorrectOnPurpose", | ||
}) | ||
c.Assert(r, IsNil) | ||
c.Assert(err, NotNil) | ||
|
||
_, err = os.Stat(repoDir) | ||
dirNotExist := os.IsNotExist(err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should be another test to check that if the directory exists, it is not removed by PlainClone. |
||
c.Assert(dirNotExist, Equals, true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The behaviour does not seem correct: it removes a directory that already existed before. go-git shouldn't remove anything it didn't create during clone. |
||
} | ||
|
||
func (s *RepositorySuite) TestPlainCloneContextWithNotEmptyDir(c *C) { | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
cancel() | ||
|
||
tmpDir := c.MkDir() | ||
repoDirPath := filepath.Join(tmpDir, "repoDir") | ||
err := os.Mkdir(repoDirPath, 0777) | ||
c.Assert(err, IsNil) | ||
|
||
dummyFile := filepath.Join(repoDirPath, "dummyFile") | ||
err = ioutil.WriteFile(dummyFile, []byte(fmt.Sprint("dummyContent")), 0644) | ||
c.Assert(err, IsNil) | ||
|
||
r, err := PlainCloneContext(ctx, repoDirPath, false, &CloneOptions{ | ||
URL: "incorrectOnPurpose", | ||
}) | ||
c.Assert(r, IsNil) | ||
c.Assert(err, Equals, ErrDirNotEmpty) | ||
} | ||
|
||
func (s *RepositorySuite) TestPlainCloneWithRecurseSubmodules(c *C) { | ||
if testing.Short() { | ||
c.Skip("skipping test in short mode.") | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Avoid additional indentation by reversing condition order:
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.
Meh, I confused
dirExist
anddirEmpty
, sorry.