Skip to content

Setting --workdir results in an empty output #1369

@ids-mau

Description

@ids-mau

Is there an existing issue for this?

  • I have searched the existing issues

Description of the bug

When setting --workdir <path> to the path of the repository or setting --workdir <parent-dir> to the parent of the repository: The git-cliff output is empty.

This used to work in 2.8.0. Maybe the meaning of --workdir changed related to some of the changes in the last few versions regarding --include-path, path resolution etc.

Steps To Reproduce

  1. Setup the repository:
    mkdir git-cliff-workdir
    cd git-cliff-workdir/
    git init
    git commit -m "feat: Changelog entry" --allow-empty
  2. These commands work as expected:
    # from inside git-cliff-workdir/
    # works
    git-cliff
    
    cd ..
    # works
    git-cliff --repository git-cliff-workdir
  3. These however, output an empty changelog:
    # from inside git-cliff-workdir/
    git-cliff --workdir .
    cd ..
    # from the parent directory of git-cliff-workdir/
    git-cliff --workdir git-cliff-workdir/
    git-cliff --repository git-cliff-workdir --workdir ./

Expected behavior

git-cliff should output the same changelog as for the other two commands, so for the example above:

## [unreleased]

### 🚀 Features

- Changelog entry

Screenshots / Logs

> ./git-cliff-workdir-repro.sh
+ mkdir git-cliff-workdir
+ cd git-cliff-workdir/
+ git init
...
+ git commit -m 'feat: Changelog entry' --allow-empty
[master (root-commit) 927f9d3] feat: Changelog entry
+ git-cliff
 WARN  git_cliff > "cliff.toml" is not found, using the default configuration
## [unreleased]

### 🚀 Features

- Changelog entry
+ git-cliff --workdir .
 WARN  git_cliff > "./cliff.toml" is not found, using the default configuration
+ cd ..
+ git-cliff --repository git-cliff-workdir
 WARN  git_cliff > "cliff.toml" is not found, using the default configuration
## [unreleased]

### 🚀 Features

- Changelog entry
+ git-cliff --workdir git-cliff-workdir/
 WARN  git_cliff > "git-cliff-workdir/cliff.toml" is not found, using the default configuration
+ git-cliff --repository git-cliff-workdir --workdir ./
 WARN  git_cliff > "./cliff.toml" is not found, using the default configuration
+ rm -rf git-cliff-workdir/

Software information

  • Project version: git-cliff 2.12.0

Additional context

Might be related to:

After further investigation:

  • Since setting --workdir now also sets the include path, empty commits without any file changes will be ignored.
  • Absolute paths passed as --workdir are not handled properly. The include patterns themselves include the absolute path, while the path of the files itself are compared using the relative path in Repository::should_retain_commit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions