Skip to content

CodeClimate::TestReporter::Git doesn't use branch_from_git_or_ci #115

Closed
@davetapley

Description

@davetapley

3efa705 introduced CodeClimate::TestReporter::Git, which includes a pair of methods: branch_from_git and branch_from_git_or_ci.

Curiously however, CodeClimate::TestReporter::Git#info uses branch_from_git, which means it doesn't have the fall back to CI logic which branch_from_git_or_ci provides.

I'm not sure if this is intentional, or an oversight?


It should be noted that the current implementation causes a failure when running the parallel test formatter without a .git directory (this was also raised on #38).

Specifically ⬇️

CodeClimate::TestReporter::Formatter.new.format SimpleCov.result

Will cause ⬇️

Coverage = 51.21%. fatal: Not a git repository: './.git'
fatal: Not a git repository: './.git'
fatal: Not a git repository: './.git'

Code Climate encountered an exception: CodeClimate::TestReporter::InvalidPayload
A git commit timestamp was not found in the test report payload

When patching it to use branch_from_git_or_ci the payload validation error goes away and the upload appears to be successful, although you will still see:

Coverage = 51.23%. fatal: Not a git repository: './.git'
fatal: Not a git repository: './.git'                   

Note that in my patch I also implement committed_at_or_now to avoid the problem of not being able to pull a commit time stamp without a .git.


So: Is there a reason to prefer branch_from_git over branch_from_git_or_ci?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions