Skip to content

Commit 4e41149

Browse files
authored
dont patch repos when url generation templates args are not provided (#56)
* don't patch url templates if cli arguments aren't provided * update changelog
1 parent 0090eb0 commit 4e41149

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ All notable changes to the ld-find-code-refs program will be documented in this
77
### Added
88
- Added support for relative paths to CLI `-dir` parameter.
99
- Added a new command line argument, `debug`, which enables verbose debug logging.
10-
- `ld-find-code-refs` will now exit early if required dependencies are not installed on the system PATH
10+
- `ld-find-code-refs` will now exit early if required dependencies are not installed on the system PATH.
1111

1212
### Changed
13-
- Renamed `parse` package to `coderefs`. The `Parse()` method in the aformentioned package is now `Scan()`
13+
- Renamed `parse` package to `coderefs`. The `Parse()` method in the aformentioned package is now `Scan()`.
14+
15+
### Fixed
16+
- `ld-find-code-refs` will no longer erroneously make PATCH API requests to LaunchDarkly when url template parameters have not been configured.
17+
1418

1519
## [0.3.0] - 2019-01-23
1620

internal/ld/ld.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,18 @@ func (c ApiClient) MaybeUpsertCodeReferenceRepository(repo RepoParams) error {
177177
CommitUrlTemplate: currentRepo.CommitUrlTemplate,
178178
HunkUrlTemplate: currentRepo.HunkUrlTemplate,
179179
}
180+
181+
// Don't patch templates if command line arguments are not provided.
182+
// This is done because the LaunchDarkly API may return autogenerated url templates for non-custom connections.
183+
if currentRepo.Type != "custom" {
184+
if repo.CommitUrlTemplate == "" {
185+
currentRepoParams.CommitUrlTemplate = ""
186+
}
187+
if repo.HunkUrlTemplate == "" {
188+
currentRepoParams.HunkUrlTemplate = ""
189+
}
190+
}
191+
180192
if !reflect.DeepEqual(currentRepoParams, repo) {
181193
err = c.patchCodeReferenceRepository(currentRepoParams, repo)
182194
if err != nil {

0 commit comments

Comments
 (0)