-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
pkg/gitutil: init #621
pkg/gitutil: init #621
Conversation
@@ -183,40 +182,6 @@ func parseVulnsFromNamespace(repositoryPath, namespace string) (vulns []database | |||
return | |||
} | |||
|
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.
Wow.
Very duplication.
So 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.
pkg/gitutil/gitutil.go
Outdated
var commandOutput []byte | ||
commandOutput, err = cmd.CombinedOutput() | ||
if err != nil { | ||
os.RemoveAll(path) |
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.
log returned error
yeah, previously it wasn't handled at all.
pkg/gitutil/gitutil.go
Outdated
func CloneOrPull(remote, desiredPath string) (path, head string, err error) { | ||
// Create a temporary directory if the path is unspecified. | ||
if desiredPath == "" { | ||
path, err = ioutil.TempDir(os.TempDir(), remote) |
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.
I don't think we should use remote
for the prefix
https://github.com/coreos/clair/pull/621/files#diff-154f97505971bb2f44a0f30045d133d2R38
We can use the updater flag I think.
pkg/gitutil/gitutil.go
Outdated
|
||
// CloneOrPull performs a git pull if the desiredPath exists on the filesystem. | ||
// Otherwise, it generates a new temporary directory and performs a git clone | ||
// to that path. |
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.
Different from the documentation here, the code only generate a new temporary directory when the desired path is not given. Is that the expected behavior?
pkg/gitutil/gitutil.go
Outdated
} | ||
|
||
// CloneOrPull performs a git pull if there is a git repository located at | ||
// desiredPath. Otherwise, it performs a git clone to that path. |
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.
nit: desired path?
This refactors the code we're using to manage temporary git repositories into a utility package.
This refactors the code we're using to manage temporary git repositories
into a utility package.