lppedd / idea-conventional-commit

Context and template-based completion for conventional/semantic commits.
https://plugins.jetbrains.com/plugin/13389-conventional-commit
MIT License
327 stars 19 forks source link

[feature request] VCS friendly custom tokens #10

Closed tad3j closed 4 years ago

tad3j commented 4 years ago

I'm sharing most of my .idea files on git, so if anyone runs the same IDE he has everything set up once he clones and opens IDEs (mostly I've added that to share complex run configurations).

I've noticed that file conventionalCommit.xml always uses full path to the file, so this won't work on another computer, where user stores his project in a different directory.

I've tried to change the XML manually with

<option name="customFilePath" value="$PROJECT_DIR$/cc_defaults.json"/>

...which seems to work, plugin settings view gets the correct path (which is full path, c:..., event after IDE restart), but after a while I notice that (I guess plugin) updates this XML back with the full path instead of using $PROJECT_DIR$. I've also tried by just entering cc_defaults.json and $PROJECT_DIR$/cc_defaults.json but the plugin doesn't recognize this syntax.

Would be really nice if this could be solved. I guess the simplest solution would just be to check if full path contains $PROJECT_DIR$'s value, if so, that part of the full path should be replaced with string "$PROJECT_DIR$", so that the output is the same as in XML code snippet above. Or I guess IDE fw for plugins may already have a helper for this?

EDIT: After going back to my IDE and committing these files to my repo, I was thinking, maybe it would make more sense to store cc_defaults.json content in conventionalCommit.xml since it's both plugin configuration kind of (maybe this wouldn't work in case one would want to store this outside the project or in another project folder, so I guess current solution is the most flexible one).

lppedd commented 4 years ago

I've thought about this. Let's fix the rules (higher precedende > lower precedence)

  1. Explicit custom file specified in settings - absolute path, or relative path if the file is inside project context (when possible)
  2. Implicit conventionalcommit.json in project base directory (when possible)
  3. Built-in tokens

Sounds good?

lppedd commented 4 years ago

This would be an overview of inner working. Posting for future reference drawing

tad3j commented 4 years ago

I've thought about this. Let's fix the rules (higher precedende > lower precedence)

1. Explicit custom file specified in settings - absolute path, or relative path if the file is inside project context (when possible)

2. Implicit `conventionalcommit.json` in project base directory (when possible)

3. Built-in tokens

Sounds good?

Nice. I think it should work. Although as said, I would store it in .idea folder, since I feel it's more related to IDE configuration than project configuration itself (on the other side, have no experience developing IDEA plugin, so I may also be wrong suggesting that :) ).

lppedd commented 4 years ago

Quick update: almost done, but the tokens are still stored in a JSON file, and I don't plan to integrate them inside the IDEA settings file.

lppedd commented 4 years ago

The error handling + UI is a pain in the ass

lppedd commented 4 years ago

Fixed with commit e5e387d8d993292a7ac610821e8891135227ef6c
I'll publish it, but there are still things to polish.

lppedd commented 4 years ago

@tad3j let me know if everything is ok :)

tad3j commented 4 years ago

When I save plugin setup on setting screen, my conventionalCommits.xml still gets full local path added c:\Users\Tad3j\... instead of $PROJECT_DIR$/cc_defaults.json. It's not a huge issue since I'm not configuring plugin often, more like nice to have.

lppedd commented 4 years ago

But you don't need to set a custom file like that if it's in project root and it's called conventionalcommit.json

Thanks!

Il ven 21 feb 2020, 18:19 tad3j notifications@github.com ha scritto:

When I save plugin setup on setting screen, my conventionalCommits.xml still gets full local path added c:\Users\Tad3j... instead of $PROJECT_DIR$/cc_defaults.json. It's not a huge issue since I'm not configuring plugin often, more like nice to have.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/lppedd/idea-conventional-commit/issues/10?email_source=notifications&email_token=AEXTPINMELA2CBVY3BLYK5DREAEL7A5CNFSM4KSYEPYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMTN4GQ#issuecomment-589749786, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEXTPILSHZ6DORY2Y33ZCV3REAEL7ANCNFSM4KSYEPYA .

tad3j commented 4 years ago

You are right, unchecking Custom default tokens and renaming the file to conventionalcommit.json solves it.