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

Fix CLI Client Handling Non-Interactive Terminal and Error Message for Non-Canonical Repo #247

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

zhijie-yang
Copy link
Contributor

Ping the @canonical/rocks team.


Description

This PR fixes the following issues:

  1. The CLI client is giving false positive results detecting non-interactive terminals.
  2. The CLI client dumps stack traceback when the regex fails to match a repo remote URL that does not belong to Canonical.

@zhijie-yang zhijie-yang requested a review from a team as a code owner September 20, 2024 10:23
@linostar linostar self-requested a review September 20, 2024 11:32
Copy link
Contributor

@linostar linostar left a comment

Choose a reason for hiding this comment

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

LGTM.

@@ -49,12 +49,16 @@ func InferBuildMetadata() BuildMetadata {
// use regex to match the repo location
regex := regexp.MustCompile("github.com[:/](canonical/.*).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.

We should only match "Push URL: ..." (even without ".git"), because there can be the case the the developer pulls from upstream and updates the repo in canonical. (Suggested by @clay-lake )

if len(matches) < 2 {
fmt.Fprintf(os.Stderr, "oci-factory must be called in a git local repository under organization [canonical]\n")
os.Exit(1)
}
source := matches[1]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then we should use matches[0] and if len(matches) == 1 to match with this change.

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