Skip to content
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

Merged
merged 1 commit into from
Sep 26, 2018
Merged

pkg/gitutil: init #621

merged 1 commit into from
Sep 26, 2018

Conversation

jzelinskie
Copy link
Contributor

This refactors the code we're using to manage temporary git repositories
into a utility package.

@jzelinskie jzelinskie added kind/cleanup no functional changes, only reorganization component/ext/vulnsrc labels Sep 14, 2018
@@ -183,40 +182,6 @@ func parseVulnsFromNamespace(repositoryPath, namespace string) (vulns []database
return
}

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

var commandOutput []byte
commandOutput, err = cmd.CombinedOutput()
if err != nil {
os.RemoveAll(path)
Copy link
Contributor

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.

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)
Copy link
Contributor

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.


// 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.
Copy link
Contributor

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 Show resolved Hide resolved
}

// CloneOrPull performs a git pull if there is a git repository located at
// desiredPath. Otherwise, it performs a git clone to that path.
Copy link
Contributor

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.
@jzelinskie jzelinskie merged commit 0ca9431 into quay:master Sep 26, 2018
@jzelinskie jzelinskie deleted the gitutil branch September 26, 2018 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/cleanup no functional changes, only reorganization
Development

Successfully merging this pull request may close these issues.

None yet

2 participants