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

Add -print0 to make gazelle scripting friendly #1028

Closed
ashi009 opened this issue Apr 10, 2021 · 3 comments · Fixed by #1213
Closed

Add -print0 to make gazelle scripting friendly #1028

ashi009 opened this issue Apr 10, 2021 · 3 comments · Fixed by #1213

Comments

@ashi009
Copy link
Contributor

ashi009 commented Apr 10, 2021

What version of gazelle are you using?

v0.22.2

What version of rules_go are you using?

v0.24.7

What version of Bazel are you using?

4.0

What did you expect to see?

We would love to use gazelle in pre-commit-hook to update build files automatically. When doing so, we need to know which build file is rewritten and needs to be added to the staging area for committing.

We propose to add -print0 flag for -mode=fix. When set, let gazelle print the names of rewritten files separated with '\0' (like other Unix tools,) then the output could be piped to xargs -r0 git add.

@jayconrod
Copy link
Contributor

Sorry to take so long to get to this.

In general, I'm hesitant to expand the user interface of Gazelle; none of the maintainers have much bandwidth to support new features.

Is there another way this problem can be solved? What about using -mode=diff, then applying that patch?

@ashi009
Copy link
Contributor Author

ashi009 commented May 16, 2021

Sorry to take so long to get to this.

In general, I'm hesitant to expand the user interface of Gazelle; none of the maintainers have much bandwidth to support new features.

Is there another way this problem can be solved? What about using -mode=diff, then applying that patch?

Already tried, but it's not working well with git.

The patch gazelle generated is not acceptable by git apply, which assumes git diff generates that. Hence, after applying it with patch I still need to find a way to get the list of changed files. So back to square one.

I already have a 10-line-ish patch for this. But still waiting for the CLA approval to upload it.

@siddharthab
Copy link
Contributor

After #1552, diff mode output will work with git apply.

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 a pull request may close this issue.

3 participants