Skip to content

Conversation

@mrodm
Copy link
Contributor

@mrodm mrodm commented Apr 26, 2024

Add support for working copies created with git worktree command.

Working copies created with this command do not have a .git folder, instead those working copies have a .git file where it is indicated where the reference repository is. For isntance:

 $ cat .git
gitdir: /home/mariorodriguez/Coding/work/elastic-package/.git/worktrees/elastic-package-add-support-git-worktree

Currently, elastic-package fails since .git is not a folder with this error:

  • In this example, build folder does not exist and elastic-package needs to create it
Error: error running package system tests: could not complete test run: can't install the package: there was an apply error: failed to build package: can't locate build directory: can't locate build packages root directory: can't create new build directory: package can be only built inside of a Git repository (.git folder is used as reference point)

@mrodm mrodm self-assigned this Apr 26, 2024
Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

Nice! Thanks for adding this. Added some comments, but mostly nitpicking.

}
var worktree gitWorktree
dec := yaml.NewDecoder(bytes.NewBuffer(content))
dec.KnownFields(true)
Copy link
Member

Choose a reason for hiding this comment

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

Nit. Do we need this? This can be an issue if some other field is added to this file, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TBH I don't know if that file could have other fields, so probably it's better to just remove it and ensure that at least the file contains "gitdir"...

"gopkg.in/yaml.v3"
)

func isGitWorktree(path string) error {
Copy link
Member

Choose a reason for hiding this comment

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

Nit. We could maybe add some test cases for this function.

@mrodm mrodm marked this pull request as ready for review April 29, 2024 09:14
@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @mrodm

@mrodm mrodm requested a review from jsoriano April 29, 2024 09:39
Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

👍

@mrodm mrodm merged commit d62d680 into elastic:main Apr 30, 2024
@mrodm mrodm deleted the add_support_git_worktree branch April 30, 2024 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants