Concisely describe the proposed feature
I noticed that ti format currently only finds diff between index and HEAD.
Here's my understanding of these terms:
git add, showing a green M 馃崗 HEAD: the last commit of the branch you are currently on.I think this diff strategy could limit its scope of what files to be formatted.
Describe the solution you'd like (if any)
Compare the diffs between index and upstream/master. In this way, so long as the changes are not merged into trunk, ti format will reformat your code.
It will be also useful to use the diff between working directory and upstream/master, so that your modified-but-not-staged changes will also be formatted. But I need to read more on GitPython to see if I can retrieve the working directory.
I'd also like to have a list of clang-format candidates to use. Right now it's fixed on clang-format-6.0, but I'm running clang-format. I think -style=file should serve as the source of truth for the formatting options, regardless of what version of clang-format you use locally. And even there is a nuance difference, thanks to the formatting server, it should be able to resolve all the diff disputes.
Additional comments
I'm amused that ti format would actually launched the Taichi runtime LOL. May be also good to separate some functions out as a lower level module (e.g. get_repo_directory())...
Compare the diffs between index and
upstream/master. In this way, so long as the changes are not merged into trunk,ti formatwill reformat your code.
I think this is a great idea! The format server has this logic:
https://github.com/taichi-dev/taichi/blob/192043ab94d3baf0a68c4cc335765af91ff43c68/misc/format_server.py#L75-L76
It finds the commit where the branch is forked from the master branch and do ti format {that commit}.
I'm amused that
ti formatwould actually launched the Taichi runtime LOL. May be also good to separate some functions out as a lower level module (e.g.get_repo_directory())...
Yeah, this is painful. When libtaichi_core has a load-time linking error, ti simply won't launch... However, fixing this is clearly not trivial.
It will also reduce the ti launch time.
Yeah, this is painful. When libtaichi_core has a linking error, ti won't launch... However, fixing this is clearly not trivial.
Ha, that's fine. I think the major issue here can be fixed in 10 LoC...
I'd also like to have a list of
clang-formatcandidates to use. Right now it's fixed onclang-format-6.0, but I'm runningclang-format. I think-style=fileshould serve as the source of truth for the formatting options, regardless of what version ofclang-formatyou use locally. And even there is a nuance difference, thanks to the formatting server, it should be able to resolve all the diff disputes.
That's true. Maybe we should autodetect available clang-format's...
Closed by #629
TODO: consider supporting .taichi in the future, so that people can customize their repo or branch names