linear-b / gitstream

/:\ gitStream - Workflow automation for your git repo. Use YAML to auto-assign reviewers, auto-merge PRs, automatic PR labeler, and more.
https://gitstream.cm
Apache License 2.0
272 stars 33 forks source link

gitStream miscategorizes the changes in PR #569

Closed avivtabak closed 3 months ago

avivtabak commented 3 months ago

Description of the problem Lately (about the last month) I noticed a wried behavior with gitStream in our Repo where it is auto-approving PRs.

For example (can't provide link to the PR since it's a private repo): When I opened a PR for a python file client.py (+16 lines added -1 removed = total of 17 lines) the gitStream bot auto-approved the CR. The bot label it as a safe-changes, so i tried to validate the conditions for save_changes automation, but couldn't find any reason to categorize the PR as safe-changes

the condition is: {{ is.safe }}

where:

docs: {{ files | allDocs }}
tests: {{ files | allTests }}
asset: {{ files | match(regex=r/\.(png|svg|gif|css)$/) | every }}
formatting: {{ source.diff.files | isFormattingChange }}
safe: {{ is.docs or is.tests or is.asset or is.formatting }}

Steps to reproduce the behavior:

  1. The .cm automation file:
    
    # -*- mode: yaml -*-
    manifest:
    version: 1.0

automations: safe_changes: if:

is: docs: {{ files | allDocs }} tests: {{ files | allTests }} asset: {{ files | match(regex=r/.(png|svg|gif|css)$/) | every }} formatting: {{ source.diff.files | isFormattingChange }} safe: {{ is.docs or is.tests or is.asset or is.formatting }}

additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }} deletions: {{ branch.diff.files_metadata | map(attr='deletions') | sum }} small_changes: {{ (is.additions + is.deletions) <= 10 }}


2. The PR URL (as it contains the repo and PR identifiers)
Can't provide as its a private repo, but can be reproduced with any dummy repo with python file

**Expected behavior**

Shouldn't give any label as it's not match the automation conditions

**Screenshots**
![image](https://github.com/user-attachments/assets/0fdc199d-7af5-4aa1-a9ac-e379592f0d35)
![image](https://github.com/user-attachments/assets/c844aed4-f55e-4d25-b971-77b4ff2edcc4)
![image](https://github.com/user-attachments/assets/cfc6b44e-ede4-40b7-aed7-02b78425a18f)
![image](https://github.com/user-attachments/assets/1953f8bf-f344-421e-9fd2-86f7d351495b)
![image](https://github.com/user-attachments/assets/41f67d90-97d2-4187-a679-438f4f0d2a82)
![image](https://github.com/user-attachments/assets/c6f4a781-9bcf-4db7-ac59-31e86a438151)
![image](https://github.com/user-attachments/assets/c98cddae-00e2-4bc8-85cc-9ae7419c552d)
PavelLinearB commented 3 months ago

Hi @avivtabak We have released a fix to our Python formatter that caused this issue. Can you please verify this is fixed on your end, too?

Thanks!