Skip to content

In-memory implementation of ls-remote using go-git to reduce repo lock contention#574

Merged
jessesuen merged 1 commit intoargoproj:masterfrom
jessesuen:go-git
Sep 11, 2018
Merged

In-memory implementation of ls-remote using go-git to reduce repo lock contention#574
jessesuen merged 1 commit intoargoproj:masterfrom
jessesuen:go-git

Conversation

@jessesuen
Copy link
Member

@jessesuen jessesuen commented Sep 11, 2018

Partially addresses #554.

This introduces go-git package to perform some of the git client functionality, namely ls-remote. It reduces repo-server lock contention by allowing the ls-remote request to happen concurrently, and without having the global lock on a repo, and without needing to clone the repo.

Copy link
Contributor

@merenbach merenbach left a comment

Choose a reason for hiding this comment

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

@jessesuen looks great! Only a minor concern regarding log message string formatting, and it's more a matter of style.

//log.Debugf("%s\t%s", hash, refName)
if ref.Name().Short() == revision {
if ref.Type() == plumbing.HashReference {
log.Debugf("revision '%s' resolved to '%s'", revision, hash)
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: Suggest using the %q formatter to quote items, if it is clear enough, without needing embedded quotation marks such as '%s'.

Copy link
Member Author

Choose a reason for hiding this comment

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

@merenbach I actually prefer our messages to use single quotes instead of double quotes, which is why I use '%s' and not %q.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, @jessesuen! Have opened #579 to help us ensure we're on the same page moving forward, since I've been using %q and should change to conform.

// If refToResolve is non-empty, we are resolving symbolic reference (e.g. HEAD).
// It should exist in our refToHash map
if hash, ok := refToHash[refToResolve]; ok {
log.Debugf("symbolic reference '%s' (%s) resolved to '%s'", revision, refToResolve, hash)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same regarding %q.

}
// We support the ability to use a truncated commit-SHA (e.g. first 7 characters of a SHA)
if IsTruncatedCommitSHA(revision) {
log.Debugf("revision '%s' assumed to be commit sha", revision)
Copy link
Contributor

Choose a reason for hiding this comment

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

%q

return strings.Fields(out)[0], nil
// If we get here, revision string had non hexadecimal characters (indicating its a branch, tag,
// or symbolic ref) and we were unable to resolve it to a commit SHA.
return "", fmt.Errorf("Unable to resolve '%s' to a commit SHA", revision)
Copy link
Contributor

Choose a reason for hiding this comment

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

%q

@jessesuen jessesuen merged commit e29d5b9 into argoproj:master Sep 11, 2018
@jessesuen jessesuen deleted the go-git branch September 11, 2018 20:55
leoluz added a commit to leoluz/argo-cd that referenced this pull request Mar 13, 2025
* fix: handle nil ParseableType from GVKParser

Signed-off-by: Leonardo Luz Almeida <leoluz@users.noreply.github.com>

* address review comments

Signed-off-by: Leonardo Luz Almeida <leoluz@users.noreply.github.com>

---------

Signed-off-by: Leonardo Luz Almeida <leoluz@users.noreply.github.com>
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