Skip to content

Commit

Permalink
support updating multiple versions per line (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
meorphis authored Jan 20, 2025
1 parent a33d12e commit 2010d20
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
20 changes: 20 additions & 0 deletions __snapshots__/generic.ts.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
exports['Generic updateContent can update multiple occurances of a versions per line 1'] = `
# Anthropic Java API Library
> [!NOTE]
> The Anthropic Java API Library is currently in _alpha_.
>
> There may be frequent breaking changes.
>
> Have thoughts or feedback? [File an issue](https://github.com/anthropics/anthropic-sdk-java/issues/new) or comment on [this thread](https://github.com/anthropics/anthropic-sdk-java/issues/30).
<!-- x-release-please-start-version -->
[![Maven Central](https://img.shields.io/maven-central/v/com.anthropic/anthropic-java)](https://central.sonatype.com/artifact/com.anthropic/anthropic-java/0.1.0-alpha.9)
[![javadoc](https://javadoc.io/badge2/com.anthropic/anthropic-java/0.1.0-alpha.9/javadoc.svg)](https://javadoc.io/doc/com.anthropic/anthropic-java/0.1.0-alpha.9)
<!-- x-release-please-end -->
The Anthropic Java SDK provides convenient access to the Anthropic REST API from applications written in Java. It includes helper classes with helpful types and documentation for every request and response property.
`

exports['Generic updateContent updates generic version markers 1'] = `
/*
* Copyright 2021 Google LLC
Expand Down
2 changes: 1 addition & 1 deletion src/updaters/generic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {Version} from '../version';
import {logger as defaultLogger, Logger} from '../util/logger';

const VERSION_REGEX =
/(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)(-(?<preRelease>[\w.]+))?(\+(?<build>[-\w.]+))?/;
/(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)(-(?<preRelease>[\w.]+))?(\+(?<build>[-\w.]+))?/g;
const SINGLE_VERSION_REGEX = /\b\d+\b/;
const INLINE_UPDATE_REGEX =
/x-release-please-(?<scope>major|minor|patch|version)/;
Expand Down
17 changes: 17 additions & 0 deletions test/updaters/fixtures/README-java-multiple-versions-per-lint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Anthropic Java API Library

> [!NOTE]
> The Anthropic Java API Library is currently in _alpha_.
>
> There may be frequent breaking changes.
>
> Have thoughts or feedback? [File an issue](https://github.com/anthropics/anthropic-sdk-java/issues/new) or comment on [this thread](https://github.com/anthropics/anthropic-sdk-java/issues/30).
<!-- x-release-please-start-version -->

[![Maven Central](https://img.shields.io/maven-central/v/com.anthropic/anthropic-java)](https://central.sonatype.com/artifact/com.anthropic/anthropic-java/0.1.0-alpha.8)
[![javadoc](https://javadoc.io/badge2/com.anthropic/anthropic-java/0.1.0-alpha.8/javadoc.svg)](https://javadoc.io/doc/com.anthropic/anthropic-java/0.0.1-alpha.8)

<!-- x-release-please-end -->

The Anthropic Java SDK provides convenient access to the Anthropic REST API from applications written in Java. It includes helper classes with helpful types and documentation for every request and response property.
13 changes: 13 additions & 0 deletions test/updaters/generic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,18 @@ describe('Generic', () => {
const newContent = pom.updateContent(oldContent);
snapshot(newContent);
});
it('can update multiple occurances of a versions per line', async () => {
const oldContent = readFileSync(
resolve(fixturesPath, './README-java-multiple-versions-per-lint.md'),
'utf8'
).replace(/\r\n/g, '\n');
const versions = new Map<string, Version>();
const updater = new Generic({
versionsMap: versions,
version: Version.parse('0.1.0-alpha.9'),
});
const newContent = updater.updateContent(oldContent);
snapshot(newContent);
});
});
});

0 comments on commit 2010d20

Please sign in to comment.