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

Refactor generic git functions into git module #5863

Merged
merged 4 commits into from
Aug 22, 2024

Conversation

r-richardson
Copy link
Contributor

@r-richardson r-richardson commented Aug 15, 2024

Refactor generic git related functions from OpenQA::Task::Git::Clone into the OpenQA::Git module for easier re-usability.
Related Ticket: 164886

Copy link
Member

@okurz okurz left a comment

Choose a reason for hiding this comment

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

If this is a prerequisite step for using the functions in other places then this looks good. If it stays like this then I am against at as functions that are only used once should be as close as possible where needed. We already discussed the possibility to keep the state within the object so that not every command needs to re-initialize or something

@r-richardson r-richardson force-pushed the refactor_use_openqa_git branch from 3d0878e to 817053d Compare August 16, 2024 10:19
@r-richardson r-richardson force-pushed the refactor_use_openqa_git branch from 817053d to 9196b67 Compare August 16, 2024 10:20
@perlpunk
Copy link
Contributor

We discussed a few things.
OpenQA::Git so far returns undef for success and the error message for a failure.
The new functions use die, and I like that more, as failures cannot be accidentally ignored, but must be catched with an eval.
We should decide on one or the other.

As another improvement I suggest another helper. Instead of

sub get_current_branch ($self) {
    my @git = $self->_prepare_git_command();
    my $r = run_cmd_with_log_return_error([@git, 'branch', '--show-current']);

we could do

sub _run_cmd ($self, $args) {
    my @git = $self->_prepare_git_command();
    return run_cmd_with_log_return_error([@git, @$args]);
}
...
sub get_current_branch ($self) {
    my $r = $self->_run_cmd(['branch', '--show-current']);

@perlpunk
Copy link
Contributor

If it stays like this then I am against at as functions that are only used once should be as close as possible where needed.

But the point of the ticket is to move all git functions to OpenQA::Git. if you are against this, we should have discussed this in the estimation.

lib/OpenQA/Git.pm Outdated Show resolved Hide resolved
lib/OpenQA/Git.pm Outdated Show resolved Hide resolved
lib/OpenQA/Task/Git/Clone.pm Show resolved Hide resolved
t/14-grutasks.t Outdated Show resolved Hide resolved
@r-richardson r-richardson force-pushed the refactor_use_openqa_git branch 2 times, most recently from 00ba185 to b7e98c8 Compare August 19, 2024 11:03
Copy link

codecov bot commented Aug 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.51%. Comparing base (ceffdd8) to head (e7eb938).
Report is 20 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5863   +/-   ##
=======================================
  Coverage   98.51%   98.51%           
=======================================
  Files         395      395           
  Lines       38782    38797   +15     
=======================================
+ Hits        38205    38220   +15     
  Misses        577      577           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

lib/OpenQA/Git.pm Outdated Show resolved Hide resolved
@r-richardson r-richardson force-pushed the refactor_use_openqa_git branch from b7e98c8 to a8b5d1b Compare August 19, 2024 11:43
@r-richardson r-richardson changed the title WIP Refactor generic git functions into git module Refactor generic git functions into git module Aug 19, 2024
lib/OpenQA/Git.pm Outdated Show resolved Hide resolved
lib/OpenQA/Git.pm Outdated Show resolved Hide resolved
@r-richardson r-richardson force-pushed the refactor_use_openqa_git branch from a8b5d1b to 6b3aa8c Compare August 19, 2024 16:53
@r-richardson r-richardson marked this pull request as ready for review August 20, 2024 08:47
lib/OpenQA/Git.pm Outdated Show resolved Hide resolved
lib/OpenQA/Git.pm Outdated Show resolved Hide resolved
lib/OpenQA/Git.pm Outdated Show resolved Hide resolved
lib/OpenQA/Git.pm Outdated Show resolved Hide resolved
lib/OpenQA/Git.pm Outdated Show resolved Hide resolved
lib/OpenQA/Git.pm Outdated Show resolved Hide resolved
okurz
okurz previously requested changes Aug 20, 2024
lib/OpenQA/Git.pm Outdated Show resolved Hide resolved
lib/OpenQA/Git.pm Outdated Show resolved Hide resolved
lib/OpenQA/Git.pm Outdated Show resolved Hide resolved
@r-richardson r-richardson force-pushed the refactor_use_openqa_git branch from 6b3aa8c to 81841da Compare August 20, 2024 08:54
lib/OpenQA/Git.pm Outdated Show resolved Hide resolved
@r-richardson r-richardson force-pushed the refactor_use_openqa_git branch from 81841da to 301acc6 Compare August 20, 2024 09:07
@r-richardson r-richardson force-pushed the refactor_use_openqa_git branch 4 times, most recently from 31cdf62 to da8b9d7 Compare August 21, 2024 10:51
lib/OpenQA/Git.pm Outdated Show resolved Hide resolved
lib/OpenQA/Git.pm Outdated Show resolved Hide resolved
@r-richardson r-richardson force-pushed the refactor_use_openqa_git branch from da8b9d7 to 7029a9f Compare August 21, 2024 11:07
Copy link
Contributor

@perlpunk perlpunk left a comment

Choose a reason for hiding this comment

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

Somehow git thinks I have started and never finished a review, so it's pending.
So I just try to submit it although I don't know what is still pending.

@r-richardson r-richardson force-pushed the refactor_use_openqa_git branch from 7029a9f to 4f0feeb Compare August 21, 2024 11:48
@r-richardson r-richardson force-pushed the refactor_use_openqa_git branch from 4f0feeb to e7eb938 Compare August 21, 2024 17:15
@perlpunk perlpunk dismissed okurz’s stale review August 21, 2024 17:34

Reviewer will be absent for a while

@mergify mergify bot merged commit f9cccde into os-autoinst:master Aug 22, 2024
43 checks passed
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.

6 participants