-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use .gitmodules for determining what hosts to keyscan #876
Conversation
Currently we use a git submodule foreach to try and get the url of all our submodules so that we can figure out if any need ssh keyscanning. This is unfortunately completely flawed as none of them exist until after we call git submodule update. This uses the git config command to parse the .gitmodule file instead.
c2c4d53
to
495969c
Compare
Nice! (out of interest, do those calls change our minimum git version by any chance?) |
(i.e. get-regexp sounds neat, and I’m wondering if it’s a later feature or something) |
What actually is our minimum git version? |
Looks like it's been in there for ages, I can see it in 1.7 |
Do we need to consider nested submodules? Looks like the previous command attempted to handle them with I wonder whether we could we feature-detect whether |
Neat, I haven't seen |
Given the current implementation just flat out doesn't work, I'd be inclined to go with this vs trying to solve recursive @matthewd. Perhaps we can add |
bootstrap/git.go
Outdated
output, err := sh.RunAndCapture( | ||
"git", "submodule", "foreach", "--recursive", "git", "ls-remote", "--get-url") | ||
"git", "config", "--file", ".gitmodules", "--null", "--get-regexp", "url") |
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.
Neat! url
seems like a very broad regexp, maybe ^submodule\..+\.url$
?
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.
⚡️
// every third element to get the [email protected]:blah bit | ||
if idx%3 == 2 { | ||
urls = append(urls, val) | ||
// splits lines on null-bytes to gracefully handle line endings and repositories with newlines |
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.
repositories with newlines
is this possible?? wow, git
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.
Yeah, I think using null-byte delimiters ends up being better practice anyway.
bootstrap/git.go
Outdated
for _, line := range lines { | ||
tokens := strings.SplitN(line, "\n", 2) | ||
if len(tokens) != 2 { | ||
return nil, fmt.Errorf("Failed to parse .gitmodule line %q", line) |
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.
.gitmodules
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.
⚡️
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.
Nice one, @lox! It really wasn't working before, huh? I guess most folks would use the same host for their main repo and submodules, probably github.com
, so we haven't noticed before?
Yeah, totally non-functional! |
Trying to integration test the submodules stuff is a bit awkward, so we missed it entirely. |
|
(kewl even) |
Currently we use a git submodule foreach to try and get the url of all our submodules so that we can figure out if any need ssh keyscanning. This is unfortunately completely flawed as none of them exist until after we call git submodule update.
This uses the git config command to parse the .gitmodule file instead.
Closes #825.