Release 0.12.0 of stevedore - minor feature enhancement
Tags: docker, stevedore, cli, ignore
Published: 2024-03-03 14:35:53

---
title: Release 0.12.0 of stevedore - minor feature enhancement 
published: true
description: Implemented handling of directories specified with postfix /
tags: docker, stevedore, cli, ignore
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2024-03-03 13:59 +0000
---
When initially I started working on `stevedore` the goal was to support `.dockerignore`, however since ignore files follow a common implementation pattern, `stevedore` can be used on other types of ignore files - if they follow the common format.

Recently I was cleaning up some repositories adding canonical ignore files, copied from: [github/gitignore](https://github.com/github/gitignore), which is a repository holding all of the ignore files offered from GitHub, these are well maintained and very useful.

Anyway in the process of doing so, I wanted to make sure how things looked, so I the question arose, can I see what is and version control and what is not, after I had updated the `.gitignore` file to the version from the GitHub repository.

The challenge here was actually from [my #48in28 Exercism participation](https://dev.to/jonasbn/do-48-programming-challenges-in-2024-48in24-3kea), where I am pretty familiar the standard layout for some repositories since I am familiar with tooling and language, working with new languages does not come with the same familiarity, so I found it made sense to use canonical definitions, hence the use of [github/gitignore](https://github.com/github/gitignore).

For example for **Clojure**

I copied the file from [github/gitignore/Clojure.gitignore](https://github.com/github/gitignore/Clojure.gitignore) to local: `.gitignore`. I actually made a fork (perhaps not necessary) and a clone so I could work on the local filesystem

```shell
cp /Users/jonasbn/develop/github-forks/gitignore/Clojure.gitignore .gitignore
```

After this I would run `stevedore`.

```shell
stevedore --ignorefile .gitignore --included --invertcolors
```

And it would inform me of the result.

```
.clj-kondo
.exercism
.exercism/config.json
.exercism/metadata.json
.git
.gitignore
.stevedoreignore
HELP.md
README.md
deps.edn
project.clj
src
src/leap.clj
test
test/leap_test.clj
```

And then the invert operation, to see what is excluded:

```shell
stevedore --ignorefile .gitignore --excluded --invertcolors
.cpcache
.cpcache/2823628308.basis
.cpcache/2823628308.cp
.cpcache/2823628308.main
.cpcache/2823628308.manifest
```

And I am pretty satisfied with the result.

A minor note on the above examples. The repository has a `.stevedoreignore` file with the following contents:

```text
.git/
```

So the `.git` directory is excluded from the analysis.

Actually if I ask `stevedore` what is exluced using it's own ignore file:

```shell
stevedore --ignorefile .stevedoreignore --excluded --invertcolors
```

I get the following:

```text
.git
```

As for the actual implementation. `stevedore` is written in **Go** and is one of the tools I am in the process of learning and `stevedore` became one of the exercises I assigned myself to get a proper example for learning **Go**.

`stevedore` uses [github.com/sabhiram/go-gitignore](https://github.com/sabhiram/go-gitignore).

It traverses the directory and makes string comparisons of the path against an instance of the above component.

If the path being inspected was a directory I would copy it and append a slash (`/`) and then check both.

```go
var aliasedPath = path

if info.IsDir() {
    aliasedPath += "/"
}

if ignoreObject.MatchesPath(path) ||  ignoreObject.MatchesPath(aliasedPath) {
```

And this worked.

Suggestions for better implementations, feedback, PRs etc. most welcome, since this was applied swiftly and it worked.

`stevedore` can be found on [GitHub](https://github.com/jonasbn/stevedore).