Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/git/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ func (r *repo) GetClonedBranch() string {
}

// Copy does copying the repository to the given destination.
// NOTE: the given “dest” must be a path that doesn’t exist yet.
// If you don't, it copies the repo root itself to the given dest as a subdirectory.
func (r *repo) Copy(dest string) (Repo, error) {
Copy link
Member Author

Choose a reason for hiding this comment

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

@nghialv btw, perhaps was this method originally created for copying the repo root to the given dest as a subdirectory?

Copy link
Member Author

Choose a reason for hiding this comment

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

@nghialv If so, my usage is just evil.

Copy link
Member Author

Choose a reason for hiding this comment

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

But even if so, it's not appropriate to give back Repo. Well, it's nothing!

Copy link
Member

Choose a reason for hiding this comment

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

The Copy function copies all the data of the original repository into a new directory.
And it expects the destination directory was not created before passing to this function.
I am sorry for the lack of explanation. We should have at least a comment.

From the current situation, I think we have 2 options:

  • keep the current behavior and add a comment to explain that the dest directory must not be created before
  • require the user to ensure that the directory must be created before passing to this function and change the command to cp -rf src/* dest

Copy link
Member Author

@nakabonne nakabonne Dec 22, 2020

Choose a reason for hiding this comment

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

One vote for the first option. In the second context, The behaviors are slightly different depending on the cp command implementation (mostly BSD and GNU). Actually cp -rf src/* dest doesn't copy the hidden files including .git/ and so on.

Let me keep the current behavior and just add a comment!

Copy link
Member

Choose a reason for hiding this comment

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

👍

cmd := exec.Command("cp", "-rf", r.dir, dest)
out, err := cmd.CombinedOutput()
Expand Down