We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 33f8c31 commit fb4b650Copy full SHA for fb4b650
1 file changed
src/common/utils/pep440Version.ts
@@ -149,6 +149,18 @@ export class PEP440Version {
149
return this.release.length > 2 ? this.release[2] : 0;
150
}
151
152
+ /**
153
+ * Returns a short display string: "X.Y.Z" if micro is present, otherwise "X.Y.x".
154
+ * Parses `input` first; returns it unchanged if not a valid version.
155
+ */
156
+ public static shortenVersionString(input: string): string {
157
+ const v = PEP440Version.parse(input);
158
+ if (!v) {
159
+ return input;
160
+ }
161
+ return v.release.length >= 3 ? `${v.major}.${v.minor}.${v.micro}` : `${v.major}.${v.minor}.x`;
162
163
+
164
/** Whether this version is a pre-release (has pre or dev segment). */
165
public get isPreRelease(): boolean {
166
return this.pre !== undefined || this.dev !== undefined;
0 commit comments