commit-analyzer icon indicating copy to clipboard operation
commit-analyzer copied to clipboard

Feature request: filter by scope

Open allforabit opened this issue 5 years ago • 14 comments

Perhaps this is already possible but after reading through the source code and checking the various dependencies I can't quite see a way of doing it. I would like to be able to filter the commits by scope. My use case is in a mono repo where I'm using the scope to denote which package a commit refers to. If this seems like a reasonable feature, I can do a pull request to implement. Some guidance here would be great, thanks!

allforabit avatar Apr 15 '20 21:04 allforabit

i second this. Am currently looking to be able to do this functionality

mattthaber avatar Jul 10 '20 19:07 mattthaber

Would this cause issues with any downstream plugins?

The issue I think right now is the commits are all pulled in by git-log-parser in semantic-release itself. It currently does not return the paths in a commit --stat option. This would be required to filter messages with some glob.

https://github.com/semantic-release/semantic-release/blob/master/lib/git.js#L48

If semantic-release is able to add that to the commit context the commit analyzer filter function in the index could could simply filter by a glob or not files: ["someDir/**", "./packages/someOtherDir/**"]

pmcjury avatar Aug 20 '20 22:08 pmcjury

I ran into the same issue, monorepo with multiple releases. I ended up creating my own plugin that wraps other plugins and filters the commits before passing them to the wrapped plugin. If anyone is interested, I can open source the commit filter

nataly87s avatar Aug 21 '20 14:08 nataly87s

@nataly87s does the commit object contain the filename/paths?

pmcjury avatar Aug 21 '20 18:08 pmcjury

@pmcjury no, I used this to get the filenames:

  const { exec } = require('child_process');

  const folders = await new Promise((resolve, reject) => {
    exec(
      `git diff-tree --no-commit-id --name-only ${commit.commit.long}`,
      (error, stdout, stderr) => {
        if (error) {
          reject(error);
          return;
        }
        if (stderr) {
          reject(new Error(stderr));
          return;
        }

        resolve(stdout.trim().split('\n'));
      }
    );
  });

nataly87s avatar Aug 22 '20 01:08 nataly87s

I ran into the same issue, monorepo with multiple releases. I ended up creating my own plugin that wraps other plugins and filters the commits before passing them to the wrapped plugin. If anyone is interested, I can open source the commit filter

I would be interested in this, since I'm running into the same issue! 🙂

sinedied avatar Mar 01 '23 16:03 sinedied

@nataly87s I'm interested in this, having same issue with monorepo

saleh199 avatar Mar 05 '23 21:03 saleh199

@sinedied @saleh199 I'll have to dig out the code from three years ago 😅 I'll do it later tonight when I have some time

nataly87s avatar Mar 05 '23 21:03 nataly87s

Thanks! In the meantime I've found a workaround using https://github.com/pmowrer/semantic-release-monorepo

sinedied avatar Mar 06 '23 09:03 sinedied

@sinedied this have only support for JS packages, but what about non-js packages

saleh199 avatar Mar 06 '23 09:03 saleh199

That's why I said it was a workaround (for me), not a universal solution 😉 We definitely miss a the ability to filter commits by scope or file path, that would solve most monorepo issues (with any language).

sinedied avatar Mar 06 '23 10:03 sinedied

Hello guys ! Any update on this feature request ?

adem-antipodestudios avatar Aug 22 '23 19:08 adem-antipodestudios

We are also interested in this.

mrclrchtr avatar Mar 04 '24 22:03 mrclrchtr