fastify / fastify/releasify

Better error handling for "Clean Repo" check

Open
#112 4 comments 2 reactions 1 assignee Claimed by @Aslam-13 View on GitHub
good first issue
Dominant language
JavaScript
Stars
65
Forks
14
PR merge metrics
No merged PRs in 30d

Description

## 🚀 Feature Proposal

When publishing we do a deep check on a clean "git status" object, and check it against the actual result of `git.status` on the path to the project we provide.

here:
https://github.com/fastify/releasify/blob/52ffba89a71f259601930656e241805d9a66c1a7/lib/commands/publish.js#L76

## Motivation

The issue is that no matter what the differences of the two objects is, the error prints:
`The git repo must be clean (committed and pushed) before releasing!`

My issue was that my branch was named "main" instead of the default "master". But the error message was throwing me off.

I propose to print the result of `assert.deepStrictEqual`, as it provides the expected vs. received, so it would flag up if the `tracking` or any other properties on those objects didn't match.

Alternatively, if we only care about the `ahead` & `behind` properties to determine the git status, we could only compare those 2 properties.

## Example

```
try {
assert.deepStrictEqual(compare, CLEAN_REPO)
} catch (err) {
console.log(err)
}
```

or something like:

```
const CLEAN_REPO = {
ahead: 0,
behind: 0
}

const compare = {
ahead: status.ahead,
behind: status.behind
}

assert.deepStrictEqual(compare, CLEAN_REPO, 'The git repo must be clean (committed and pushed) before releasing!')

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.