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 missing cast to hash in repo discovery script #212

Merged
merged 8 commits into from Mar 20, 2024

Conversation

howcanunot
Copy link
Contributor

@howcanunot howcanunot commented Mar 17, 2024

Fix this exception in discovery-repos.rb script

cam/steps/discover-repos.rb:125:in `<main>': undefined method `values' for an instance of Array (NoMethodError)
lines = [found.first[1].keys.join(',')] + found.values.map { |m| m.values.join(',') }
Did you mean?  values_at

#211

@howcanunot howcanunot changed the title [#211] Fix missing cast to hash in repo discovery script Fix missing cast to hash in repo discovery script Mar 17, 2024
@yegor256
Copy link
Owner

@howcanunot thanks for the fix! Would be great to supplement the fix with a unit test. Otherwise, how do we know anything was fixed?

@howcanunot
Copy link
Contributor Author

howcanunot commented Mar 18, 2024

@howcanunot thanks for the fix! Would be great to supplement the fix with a unit test. Otherwise, how do we know anything was fixed?

What is the best way to add such a test? Would it be enough to add extra case to tests/steps/test-discover-repos.sh?

@yegor256
Copy link
Owner

@howcanunot yes, most probably this will be enough. In general, before fixing code, try to reproduce the bug in a test. You should run make test and it should fail. Then, you fix the code and the test passes. Only then you make a pull request.

@howcanunot
Copy link
Contributor Author

howcanunot commented Mar 18, 2024

some changes in commit:

  • in dry_run script mode we should get not only single repo but page-size for every iteration, just like in normal mode
  • extra test to verify that we were able to grep a sufficiently large number of repos

make test TEST=tests/steps/test-discover-repos.sh without fix:

cam/steps/discover-repos.rb:124:in `<main>': undefined method `values' for an instance of Array (NoMethodError)

lines = [found.first[1].keys.join(',')] + found.values.map { |m| m.values.join(',') }
                                               ^^^^^^^
Did you mean?  values_at
❌ Non-zero exit code (TARGET=cam/test-zone/steps/test-discover-repos.sh/target)

@howcanunot
Copy link
Contributor Author

@yegor256 Good afternoon! Can you please check this pr?

else
github.search_repositories(query, per_page: size, page: page)
end
puts(json)
Copy link
Owner

Choose a reason for hiding this comment

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

@howcanunot this is a debug output?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ouch..
yeap, I'll remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done
thanks!

@yegor256
Copy link
Owner

@rultor merge

@rultor
Copy link
Collaborator

rultor commented Mar 20, 2024

@rultor merge

@yegor256 OK, I'll try to merge now. You can check the progress of the merge here

@rultor rultor merged commit 09ca599 into yegor256:master Mar 20, 2024
5 checks passed
@rultor
Copy link
Collaborator

rultor commented Mar 20, 2024

@rultor merge

@yegor256 Done! FYI, the full log is here (took me 17min)

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.

None yet

3 participants