danger / danger/danger-js

Paths are relative to git folder

Open
#971 1 comment 0 reactions 0 assignees View on GitHub
You Can Do This
Dominant language
TypeScript
Stars
5.5k
Forks
381
Avg merge
2h 8m
Merged PRs (30d)
6

Description

When running `danger local` the list of modified and created files is relative to the git folder. Which makes it hard to actually read the contents of the files (need to detect what the path of the git repo is) or even execute other commands if you are not executing danger from the top level folder.

Either adding a new field to the `git` section with the path of the repo, or making the paths relative to the current directory would solve the issue.

For example, in my repo, when running `danger local` from the `foo` directory I get the following output:

```js
{
git: {
fileMatch: [Function],
modified_files: [ 'package-lock.json', 'package.json' ],
created_files: [ 'README', 'dangerfile.local.ts', 'foo/dangerfile.local.ts' ],
deleted_files: [],
commits: [ [Object] ],
diffForFile: [Function: diffForFile],
structuredDiffForFile: [Function: structuredDiffForFile],
JSONPatchForFile: [Function: JSONPatchForFile],
JSONDiffForFile: [Function: JSONDiffForFile],
linesOfCode: [Function: linesOfCode]
},
github: null,
bitbucket_server: ,
bitbucket_cloud: ,
gitlab: undefined,
utils: { sentence: [Function: sentence], href: [Function: href] }
}
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the behavior described for `danger local` when run from the `foo` directory, and inspect how the `git` section produces `modified_files` and `created_files`. Compare the two proposed resolutions—adding the repository path or making paths relative to the current directory—and verify that file reading and other commands work from a subdirectory.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.