Skip to content

Commit 8fb6600

Browse files
author
Arnold Trakhtenberg
authored
Implement coderefs search in native go (#126)
* first pass - support all options via cobra for command line usage * cleanup, compatability with wrappers * update changelog * lint * update orb * remove delimiters from orb * update version string * length guard * first pass - move search code to a search package * clean up the Searcher interface, fix tests * first pass at support for ripgrep * update readme * add homebrew dependency * native client take 1 * testing stuff * cleanup * cleanup docs and options * more cleanup * fixes and tests * move file reading code to a separate... file * comments * remove unused code * simplify hunk consolidation code * add comment * refactor some stuff into a separate method * add more tests * sort hunks by flag key in tests for stability * lint * address review * fix race in tests * lint * don't write to closed channel * read files concurrently * fix lint
1 parent 41b778a commit 8fb6600

30 files changed

Lines changed: 794 additions & 1902 deletions

.goreleaser.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ brew:
4949

5050
url_template: "https://github.com/launchdarkly/ld-find-code-refs/releases/download/{{ .Tag }}/{{ .ArtifactName }}"
5151

52-
dependencies:
53-
- "ag"
54-
5552
install: |
5653
bin.install "ld-find-code-refs"
5754

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,19 @@ All notable changes to the ld-find-code-refs program will be documented in this
1616
```
1717
- All command line flags can now be specified as environment variables.
1818
19+
### Fixed
20+
21+
- Exlude negations in `.ldignore` (lines beginning with an exlamation mark) now correctly include files.
22+
1923
### Changed
2024

21-
- The underlying command line package has been changed for improved ergonomics when configuring options using the command line. Some existing configurations may be invalid, see `ld-find-code-refs --help` for details.
25+
- The command line tool has been changed for improved ergonomics when configuring options using the command line. Some existing configurations may be invalid, see `ld-find-code-refs --help` for details.
2226

2327
### Removed
2428

2529
- The `exclude` command-line option has been removed. Use the `.ldignore` file instead.
2630
- Additional delimiters can no longer be specified using command line flags or environment variables. If you use additional delimiters, or would like to disable delimiters completely, use the YAML configuration described above.
31+
- `ld_find_code_refs` no longer requires the silver searcher (ag) as a runtime dependency.
2732

2833
## [1.5.0] - 2020-05-11
2934

README.md

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,25 @@ This repository provides solutions for configuring [LaunchDarkly code references
2929

3030
We provide turnkey support for common trigger mechanisms and CI / CD providers. You can also invoke the ld-find-code-refs utility from the command line, which can be run in any custom workflow you define (e.g. from a bash script, or a cron job).
3131

32-
| System | Status |
33-
| ---------------- | --------------------------------------------------------------------------------- |
34-
| GitHub Actions | [Supported](https://docs.launchdarkly.com/v2.0/docs/github-actions) |
35-
| CircleCI Orbs | [Supported](https://docs.launchdarkly.com/v2.0/docs/circleci-orbs) |
36-
| Bitbucket Pipes | [Supported](https://docs.launchdarkly.com/v2.0/docs/bitbucket-pipes-coderefs) |
37-
| GitLab CI | [Supported](https://docs.launchdarkly.com/integrations/git-code-references/gitlab-ci)
38-
| Manually via CLI | [Supported](https://docs.launchdarkly.com/v2.0/docs/custom-configuration-via-cli) |
32+
| System | Status |
33+
| ---------------- | ------------------------------------------------------------------------------------- |
34+
| GitHub Actions | [Supported](https://docs.launchdarkly.com/v2.0/docs/github-actions) |
35+
| CircleCI Orbs | [Supported](https://docs.launchdarkly.com/v2.0/docs/circleci-orbs) |
36+
| Bitbucket Pipes | [Supported](https://docs.launchdarkly.com/v2.0/docs/bitbucket-pipes-coderefs) |
37+
| GitLab CI | [Supported](https://docs.launchdarkly.com/integrations/git-code-references/gitlab-ci) |
38+
| Manually via CLI | [Supported](https://docs.launchdarkly.com/v2.0/docs/custom-configuration-via-cli) |
3939

4040
## Execution via CLI
4141

4242
The command line program may be run manually, and executed in an environment of your choosing. The program requires your `git` repo to be cloned locally, and the currently checked out branch will be scanned for code references.
4343

44-
We recommend ingraining `ld-find-code-refs` into your CI/CD build process. `ld-find-code-refs` should run whenever a commit is pushed to your repository.
44+
We recommend incorporating `ld-find-code-refs` into your CI/CD build process. `ld-find-code-refs` should run whenever a commit is pushed to your repository.
4545

4646
### Prerequisites
4747

48-
`ld-find-code-refs` has two dependencies, which need to be installed in the system path:
48+
`ld-find-code-refs` requires git (tested with version 2.21.0) to be installed on the system path.
4949

50-
| Dependency | Version Tested |
51-
| ------------------------------------------------------------------------- | -------------- |
52-
| git | 2.21.0 |
53-
| [ag (the_silver_searcher)](https://github.com/ggreer/the_silver_searcher) | 2.2.0 |
54-
55-
All turn-key configuration methods (docker images used by services like CircleCI or Github actions) come with these dependencies preinstalled.
50+
All turn-key configuration methods (docker images used by services like CircleCI or Github actions) come with git preinstalled.
5651

5752
### Installing
5853

@@ -74,8 +69,6 @@ We do not yet have repositories set up for our linux packages, but we do upload
7469
This shell script can be used to download and install `ag` and `ld-find-code-refs` on Ubuntu.
7570

7671
```bash
77-
apt-get install silversearcher-ag
78-
7972
wget -qO- https://api.github.com/repos/launchdarkly/ld-find-code-refs/releases/latest \
8073
| grep "browser_download_url" \
8174
| grep "amd64.deb" \
@@ -87,16 +80,8 @@ dpkg -i ld-find-code-refs.amd64.deb
8780

8881
#### Windows
8982

90-
**Note**: The underlying dependency used for search, `ag`, has known performance issues when built for Windows. Unofficial Windows builds are available for `ag` from various forks on GitHub, although correctness and performance cannot be guaranteed. If you are experiencing issues running `ld-find-code-refs` on Windows, we recommend using the [Docker image](#docker) instead.
91-
9283
A Windows executable of `ld-find-code-refs` is available on the [releases page](https://github.com/launchdarkly/ld-find-code-refs/releases/latest).
9384

94-
The following Chocolatey command may be used to install the required dependency, `ag`. If you do not have Chocolatey installed, see `ag`'s documentation for [installation instructions](https://github.com/ggreer/the_silver_searcher#windows).
95-
96-
```powershell
97-
choco install ag
98-
```
99-
10085
#### Docker
10186

10287
`ld-find-code-refs` is available as a [docker image](https://hub.docker.com/r/launchdarkly/ld-find-code-refs). The image provides an entrypoint for `ld-find-code-refs`, to which command line arguments may be passed. If using the entrypoint, your git repository to be scanned should be mounted as a volume. Otherwise, you may override the entrypoint and access `ld-find-code-refs` directly from the shell.
@@ -111,7 +96,7 @@ docker run \
11196

11297
#### Manual
11398

114-
Precompiled binaries for the latest release can be found [here](https://github.com/launchdarkly/ld-find-code-refs/releases/latest). Be sure to install the required [dependencies](#prerequisities) before running `ld-find-code-refs`
99+
Precompiled binaries for the latest release can be found [here](https://github.com/launchdarkly/ld-find-code-refs/releases/latest). Be sure to install the required [dependencies](#prerequisities) before running `ld-find-code-refs`.
115100

116101
### CLI Configuration
117102

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ require (
88
github.com/launchdarkly/api-client-go v0.0.0-20181031211650-fe4f1d017b6e
99
github.com/launchdarkly/json-patch v0.0.0-20180720210516-dd68d883319f
1010
github.com/mattn/go-runewidth v0.0.4 // indirect
11+
github.com/monochromegane/go-gitignore v0.0.0-20160105113617-38717d0a108c
1112
github.com/olekukonko/tablewriter v0.0.1
1213
github.com/spf13/cobra v1.0.0
1314
github.com/spf13/pflag v1.0.5
1415
github.com/spf13/viper v1.6.3
1516
github.com/stretchr/testify v1.3.0
1617
golang.org/x/oauth2 v0.0.0-20181120190819-8f65e3013eba // indirect
18+
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4
19+
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384
1720
google.golang.org/appengine v1.3.0 // indirect
1821
gopkg.in/yaml.v2 v2.2.8 // indirect
1922
)

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh
8787
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
8888
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
8989
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
90+
github.com/monochromegane/go-gitignore v0.0.0-20160105113617-38717d0a108c h1:RRUev95N3Gq4Aog4avFzXJA2V8fgXmND+cvcH7KLMyk=
91+
github.com/monochromegane/go-gitignore v0.0.0-20160105113617-38717d0a108c/go.mod h1:Pm3mSP3c5uWn86xMLZ5Sa7JB9GsEZySvHYXCTK4E9q4=
9092
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
9193
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
9294
github.com/olekukonko/tablewriter v0.0.1 h1:b3iUnf1v+ppJiOfNX4yxxqfWKMQPZR5yoh8urCTFX88=
@@ -163,6 +165,7 @@ golang.org/x/oauth2 v0.0.0-20181120190819-8f65e3013eba h1:YDkOrzGLLYybtuP6ZgebnO
163165
golang.org/x/oauth2 v0.0.0-20181120190819-8f65e3013eba/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
164166
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
165167
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
168+
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
166169
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
167170
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
168171
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -176,6 +179,7 @@ golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxb
176179
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
177180
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
178181
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
182+
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384 h1:TFlARGu6Czu1z7q93HTxcP1P+/ZFC/IKythI5RzrnRg=
179183
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
180184
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
181185
google.golang.org/appengine v1.3.0 h1:FBSsiFRMz3LBeXIomRnVzrQwSDj4ibvcRexLG0LZGQk=

internal/command/command.go

Lines changed: 0 additions & 140 deletions
This file was deleted.

internal/command/command_test.go

Lines changed: 0 additions & 96 deletions
This file was deleted.

0 commit comments

Comments
 (0)