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

lab 0.18.0 behavior change #558

Closed
chenrui333 opened this issue Jan 7, 2021 · 11 comments
Closed

lab 0.18.0 behavior change #558

chenrui333 opened this issue Jan 7, 2021 · 11 comments

Comments

@chenrui333
Copy link

👋 looks like the lab 0.18.0 behavior got changed (it requires the gitlab PAT before proceeding to do something meaningful) and now the test started not working.

    ENV["LAB_CORE_USER"] = "test_user"
    ENV["LAB_CORE_HOST"] = "https://gitlab.com"
    ENV["LAB_CORE_TOKEN"] = "dummy"
    ENV["GIT_AUTHOR_NAME"] = "test user"
    ENV["GIT_AUTHOR_EMAIL"] = "test@example.com"
    ENV["GIT_COMMITTER_NAME"] = "test user"
    ENV["GIT_COMMITTER_EMAIL"] = "test@example.com"
    system "git", "init"
    %w[haunted house].each { |f| touch testpath/f }
    system "git", "add", "haunted", "house"
    system "git", "commit", "-a", "-m", "Initial Commit"
    assert_equal "haunted\nhouse", shell_output("#{bin}/lab ls-files").strip

Interesting enough, I found the similar test code in the codebase. Not sure if some real test token was used in the goreleaser process.

relates to Homebrew/homebrew-core#68377

@bmeneg
Copy link
Collaborator

bmeneg commented Jan 7, 2021

Hi @chenrui333 , thanks for opening this issue.
I'll take a look on it and also make sure we have a test for catching it earlier.
Sorry for the incovinience.

@bmeneg bmeneg self-assigned this Jan 7, 2021
@chenrui333
Copy link
Author

no worries, thanks for picking this up.

@chenrui333
Copy link
Author

Any updates?

@bmeneg
Copy link
Collaborator

bmeneg commented Jan 9, 2021

Any updates?

Not yet, sorry.
Didn't have time to look at it :( but I'll give my word I'll take care of it early next week (Monday).

@prarit
Copy link
Collaborator

prarit commented Jan 11, 2021

@bmeneguele @chenrui333 : I think I have a solution. Will update in a minute.

prarit added a commit to prarit/lab that referenced this issue Jan 11, 2021
chenrui333 noted in zaquestion#558 that the goreleaser test for lab was failing.
The test is a simple execution of the git wrapper capabilities of lab.

The test does:

	git init
	touch haunted
	touch house
	git add haunted house
	git commit -a -m "Initial Commit"
	lab ls-files

and expects the output of the last command to be

	haunted
	house

The test currently fails on the command line with

[prarit@prarit dummy (master)]$ LAB_CORE_HOST=foo LAB_CORE_USER=bar LAB_CORE_TOKEN=baz lab  ls-files
Create a token with scope 'api' here: profile/personal_access_tokens
Enter default GitLab token, or leave blank to provide a command to load the token:

instead of displaying the list of files.  This occurs because the code
does not check to see if LAB_CORE_TOKEN is set before querying the user
for a token.

Check that LAB_CORE_TOKEN is set before querying the user for the token.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Reported-by: @chenrui333 (in zaquestion#558)
Cc: Bruno Meneguele <bmeneg@redhat.com>
@bmeneg
Copy link
Collaborator

bmeneg commented Jan 11, 2021

@prarit thanks for the help :) didn't have time to get a closer look at it.
One thing I noticed is that lab -h and lab --help have different behaviors too: the first requires API auth, while the last doesnt.
But I think it's something for another issue.

@bmeneg bmeneg removed their assignment Jan 11, 2021
@prarit
Copy link
Collaborator

prarit commented Jan 11, 2021

@prarit thanks for the help :) didn't have time to get a closer look at it.
One thing I noticed is that lab -h and lab --help have different behaviors too: the first requires API auth, while the last doesnt.
But I think it's something for another issue.

I think it has something to do with the way we're wrapping 'git'. 'lab -h' outputs the git help, while 'lab --help' outputs lab's help.

@chenrui333
Copy link
Author

much better than last time

==> /usr/local/Cellar/lab/0.18.0/bin/lab ls-files
2021/01/11 15:34:30 root.go:146: No default remote found
Error: lab: failed
An exception occurred within a child process:
  Test::Unit::AssertionFailedError: <"haunted\n" + "house"> expected but was
<"Config saved to /private/tmp/lab-test-20210111-16852-15321lo/.config/lab/lab.toml\n" +
"haunted\n" +
"house">.

diff:
+ Config saved to /private/tmp/lab-test-20210111-16852-15321lo/.config/lab/lab.toml
  haunted
  house

folded diff:
+ Config saved to /private/tmp/lab-test-20210111-16852-15321lo/.config/lab/lab.t
+ oml
  haunted
  house

prarit added a commit to prarit/lab that referenced this issue Jan 11, 2021
chenrui333 noted in zaquestion#558 that the goreleaser test for lab was failing.
The test is a simple execution of the git wrapper capabilities of lab.

The test does:

	git init
	touch haunted
	touch house
	git add haunted house
	git commit -a -m "Initial Commit"
	lab ls-files

and expects the output of the last command to be

	haunted
	house

The test currently fails on the command line with

[prarit@prarit dummy (master)]$ LAB_CORE_HOST=foo LAB_CORE_USER=bar LAB_CORE_TOKEN=baz lab  ls-files
Create a token with scope 'api' here: profile/personal_access_tokens
Enter default GitLab token, or leave blank to provide a command to load the token:

instead of displaying the list of files.  This occurs because the code
does not check to see if LAB_CORE_TOKEN is set before querying the user
for a token.

Check that LAB_CORE_TOKEN is set before querying the user for the token.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Reported-by: @chenrui333 (in zaquestion#558)
Cc: Bruno Meneguele <bmeneg@redhat.com>
@prarit
Copy link
Collaborator

prarit commented Jan 11, 2021

Thanks @chenrui333, I've added one additonal change. Can you do another test on #559 ?

@bmeneg
Copy link
Collaborator

bmeneg commented Jan 11, 2021

@prarit thanks for the help :) didn't have time to get a closer look at it.
One thing I noticed is that lab -h and lab --help have different behaviors too: the first requires API auth, while the last doesnt.
But I think it's something for another issue.

I think it has something to do with the way we're wrapping 'git'. 'lab -h' outputs the git help, while 'lab --help' outputs lab's help.

Yes, it is. Last time I changed the code I didn't notice the diff. I'm going to review it.

prarit added a commit to prarit/lab that referenced this issue Jan 11, 2021
chenrui333 noted in zaquestion#558 that the goreleaser test for lab was failing.
The test is a simple execution of the git wrapper capabilities of lab.

The test does:

	git init
	touch haunted
	touch house
	git add haunted house
	git commit -a -m "Initial Commit"
	lab ls-files

and expects the output of the last command to be

	haunted
	house

The test currently fails on the command line with

[prarit@prarit dummy (master)]$ LAB_CORE_HOST=foo LAB_CORE_USER=bar LAB_CORE_TOKEN=baz lab  ls-files
Create a token with scope 'api' here: profile/personal_access_tokens
Enter default GitLab token, or leave blank to provide a command to load the token:

instead of displaying the list of files.  This occurs because the code
does not check to see if LAB_CORE_TOKEN is set before querying the user
for a token.

Check that LAB_CORE_TOKEN is set before querying the user for the token.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Reported-by: @chenrui333 (in zaquestion#558)
Cc: Bruno Meneguele <bmeneg@redhat.com>
@chenrui333
Copy link
Author

Close as it is resolved. Thanks @prarit @bmeneguele!

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

No branches or pull requests

3 participants