Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Unable to stage hunks or lines of code in JS files

jordangehman April 17, 2021

When I try to stage individual hunks or lines of code from a file, they appear to be staged correctly and the rest of the file remains unstaged. However, after I submit my commit, the entire file is committed.

I've noticed this happening a little prior to March 18th. I suspect it might only be happening in JS files, but I haven't 100% confirmed this to be the case yet.

Has anyone else encountered this issue?

1 answer

0 votes
Daniel Eads
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 19, 2021

Hey @jordangehman , welcome to the Community!

I haven't seen other mentions of this issue yet but would love to try and reproduce it. What OS and version of Sourcetree are you on? It also sounds odd that it would be restricted to a particular filetype (it's all text to git/sourcetree), but what other languages or filetypes besides javascript do you typically work with?

Thanks,
Daniel

jordangehman April 19, 2021

Thanks Daniel! I agree this seems like an odd issue I've encountered.

I'm on MacOS Big Sur 11.2.3 using Sourcetree version 4.1.0.

I also work in a lot of PHP and SCSS files. I will try to reproduce it soon and get back to you.

jordangehman April 26, 2021

@Daniel Eads I have confirmed I can only reproduce this in one specific React project, and it only happens when making commits from `.js` files. What information would be helpful for me to share to help identify the issue?

jordangehman April 26, 2021

@Daniel Eads I got some more information from a coworker. This particular React project has a pre-commit hook installed via Husky. As part of committing, it runs lint and prettier. From the `package.json` file:

"husky": {
    "hooks": {
        "pre-commit": "lint-staged"
    }
},
"lint-staged": {
    "*.{js,json,jsx,css,md}": [
        "prettier --write",
        "git add"
    ]
},

It seems likely that this is the culprit; there is probably a conflict with this and SourceTree that causes the app to commit the entire file.

Daniel Eads
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 26, 2021

Great, thanks for the additional context! I've tapped the Sourcetree development team for their insights here and hope to have something for you shortly.

Like jordangehman likes this
Alan Francis
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 10, 2021

Hi @jordangehman ,
We are currently looking into this issue and we hope we can come up with a fix soon.
We will update here once we figure out that.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events