wert007 / commit-analyzer

Gets the time somebody worked on something from `git log`
MIT License
1 stars 1 forks source link

[Enhancement] Time Frames and Search Scopes #21

Open kevinmatthes opened 2 years ago

kevinmatthes commented 2 years ago

To make reading from the CSV report the application compiles easier, it would be nice to specify a number of time frames depending on the configured duration. The frame starts with the first commit on that day and ends with the latest commit which still fits the given duration. If the duration exceeds, a new frame starts. Single commits would become frames on their own. The application should support up to five or six time frames to be called with the --frame <INTEGER> option, optional shorthand: -F, being zero by default. In case one frame is empty but configured, no string will be written to the report for that CSV field.

The second thing is a search scope. When a time pattern with a fixed format is given using the --scope <TIMESTAMP> option, optional shorthand: -S, only commits which match this time pattern will be revealed for analysis. Example:

commit-analyzer --git --scope 202205.. # Read from the local Git history, only take care for May 2022.

What do you think about these suggestions, @wert007?

wert007 commented 2 years ago

Hmm, what would the time frame feature be for?

Hmm, sounds interesting, but I think specifying the date format could be a little bit tricky. Like should this be fixed, to always specify a year and a month? Or are other specifications possible? If it is the former then I think scope is to generic, since it basically is just a monthly filter.

kevinmatthes commented 2 years ago

The time frames are for the Excel report; there is a Rust crate to write to Excel sheets and I intended the time frames to be the input information. And yes, a filter by year and month would totally suffice; I just thought a more generic processing would be nice, as well.

kevinmatthes commented 2 years ago

I thought this crate might work: https://github.com/outersky/simple_excel_writer.

But unfortunately, it is Apache 2.0 and thus higher than commit-analyzer. There were two other crates, as well, but I need to look for their licenses at first; they are excel_writer and basic_xlsx_writer.

wert007 commented 2 years ago

The time frames are for the Excel report; there is a Rust crate to write to Excel sheets and I intended the time frames to be the input information. And yes, a filter by year and month would totally suffice; I just thought a more generic processing would be nice, as well.

I still do not quite get, how the time frames are useful for that. 😅 Might be, but that would also turn into a lot of overengineering. I think it would be too hard doing it right, so a simple filter option should suffice.

I thought this crate might work: https://github.com/outersky/simple_excel_writer.

But unfortunately, it is Apache 2.0 and thus higher than commit-analyzer. There were two other crates, as well, but I need to look for their licenses at first; they are excel_writer and basic_xlsx_writer.

Not being a lawyer and stuff, but using it as a library in this code base should be fine.

kevinmatthes commented 2 years ago

Licenses need to be compatible with each other. MIT is upward compatible with Apache 2.0 such that any MIT stuff can be used in Apache 2.0 projects without any restrictions.

But Apache 2.0 is not downward compatible with MIT such that any Apache 2.0 stuff cannot be used in MIT projects. It would be a license infringement.

To take care about this problem, many Rust projects are dual-licensed MIT and Apache 2.0, including Rust itself. Dual-licensed projects are known to OR their licenses.

To solve this problem, you could add a further license to your project -- namely Apache 2.0 -- or we employ another library therefore. The latter option is the easier one.

kevinmatthes commented 2 years ago

People who need to create such Excel reports often need to specify multiple time frames in those. This is why I would like to implement a time frame feature in commit-analyzer.

For an example of how such a time frame structure looks like, just ask @Ranplax to show you one of his future report forms, for instance the form for December 2022.

wert007 commented 2 years ago

Okay, I researched a little bit, the reason everything in rust is often dual licensed is, because the primary license is Apache 2.0, but add MIT to be GPL compatible. Adding Apache 2.0 crates in your Cargo.toml is totally fine. source

kevinmatthes commented 2 years ago

Thank you for your research. Could you please summarise the ideas of the source? Honestly, I have no idea how read those reddit threads since there is no clear relationship between the single messages...

wert007 commented 2 years ago

All of those licenses are "permissive"/"non-protective" licenses (naming depends on whether you want to highlight their pros or cons) and they are very much free to use as dependencies. Your choice of license for your own crate is not restricted by them. [1]

[1] ...unless you are releasing your crate into the public domain, in which case you cannot "embed" them (using them is fine).

Basically this answer. So embedding the code by cloning the git repository would be problematic (then again I think, that would be doable), but just adding a dependency to the toml file is totally fine.

kevinmatthes commented 2 years ago

Since there are multiple implementations to choose from, we should take a look at all of them since their APIs can be expected to differ. This might be an important reason to search for alternatives anyway. We should choose the crate with the most comfortable API for this use case.

kevinmatthes commented 2 years ago

This seems to be the crate with the most features and some recent activity: https://github.com/informationsea/xlsxwriter-rs (Apache 2.0).

Do you know any other crates with MIT license, recent changes in the repository, access to the repository at all and functionality to read from as well as write to Excel files?

wert007 commented 2 years ago

This seems to be the crate with the most features and some recent activity: https://github.com/informationsea/xlsxwriter-rs (Apache 2.0).

I mean, there is no need to have the most features, is there?

Do you know any other crates with MIT license, recent changes in the repository, access to the repository at all and functionality to read from as well as write to Excel files?

No, I have never tried writing anything to excel files in rust, nor have I read from people trying to do it.

wert007 commented 2 years ago

Since there are multiple implementations to choose from, we should take a look at all of them since their APIs can be expected to differ. This might be an important reason to search for alternatives anyway. We should choose the crate with the most comfortable API for this use case.

Hmm, maybe you should define, how this program should write to excel files. How it should interact with excel files and what formatting it should do. And how configurable it should be.