Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Add version in code #182

Closed
dblock opened this issue Apr 19, 2024 · 6 comments
Closed

[FEATURE] Add version in code #182

dblock opened this issue Apr 19, 2024 · 6 comments
Labels
enhancement New feature or request untriaged

Comments

@dblock
Copy link
Member

dblock commented Apr 19, 2024

Is your feature request related to a problem?

Looking at the code of the library one can't tell which version it is. Only a release tag makes it a certain version. This makes it difficult to reliably know what version users are reporting bugs against. We also likely want to use the version in the future to add a User-Agent header.

What solution would you like?

  1. Add a version in code and/or composer.json, document incrementing it, follow semver.
  2. Add a test that ensures version can be retrieved dynamically.

Do you have any additional context?

Examples of other libraries that do that: https://github.com/opensearch-project/opensearch-ruby/blob/6bafe83e7b7014c6a012399ec77a03b19d335993/lib/opensearch/version.rb#L28

@shyim
Copy link
Collaborator

shyim commented Apr 19, 2024

We can just use InstalledVersions::getVersion('opensearch-project/opensearch-php'); and then we get the version, it's provided by the Composer package manager.

I would not add something to the source code.

@dblock
Copy link
Member Author

dblock commented Apr 19, 2024

I am not super familiar with how this is done in PHP, so just trying to learn ;)

That works for released versions, but what does this return, or I should probably ask, how does one use the code that is unreleased on main?

@shyim
Copy link
Collaborator

shyim commented Apr 19, 2024

composer uses then the current branch, or we can set branch aliases, so when you are on branch 2.x, please use 2.999.999

@dblock
Copy link
Member Author

dblock commented Apr 19, 2024

So the PHP way of doing it is like so:

  "repositories": [
    {
      "type": "package",
      "package": {
        "name": "opensearch-project/opensearch-php",
        "version": "2.9999",
        "source": {
          "url": "https://github.com/opensearch-project/opensearch-php",
          "type": "git",
          "reference": "main"
        }
      }
    }
  ],
  "require": {
    "opensearch-project/opensearch-php": "^2.0"
  }

Having to specify the version like you suggest puts the burden on the user to know what version is on main currently. Isn't that an anti-pattern? Shouldn't code know what version it is?

@dblock
Copy link
Member Author

dblock commented Apr 19, 2024

Btw, if this is just not the way things are done in PHP we can close this.

@dblock
Copy link
Member Author

dblock commented Apr 23, 2024

So we do have a version in code, https://github.com/opensearch-project/opensearch-php/blob/main/src/OpenSearch/Client.php#L55, and it's out of date.

@dblock dblock closed this as completed Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request untriaged
Projects
None yet
Development

No branches or pull requests

2 participants