[Add] VersionCheck #215
No reviewers
Labels
No Label
has/backport
has/pull
in progress
invalid
kind/breaking
kind/bug
kind/build
kind/deployment
kind/docs
kind/enhancement
kind/feature
kind/lint
kind/proposal
kind/question
kind/refactor
kind/security
kind/testing
kind/translation
kind/ui
need/backport
priority/critical
priority/low
priority/maybe
priority/medium
reviewed/duplicate
reviewed/invalid
reviewed/wontfix
skip-changelog
status/blocked
status/needs-feedback
status/needs-reviews
status/wip
upstream/gitea
No Milestone
No Assignees
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: gitea/go-sdk#215
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "6543/go-sdk:version-check"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
add function to check gitea versions
use versionCheck for new introduced APIs of gitea_v1.11.0
close #197
version-checkto [Add] VersionCheck@ -19,3 +22,3 @@
// Version return the library version
func Version() string {
return "0.12.3"
return "0.11.0"
I don't think we can really reduce the version of the library - I see what you're trying to do though - maybe we should just make it 1.11.0?
I dont like to go out of 0.x jet :https://medium.com/@aman.sardana/go-modules-versioning-dependency-management-d5f96b490774
"...version 0 is an exception for backward compatibility rule of golang as the version updated before version 1 can be backward incompatible. It is best for the libraries that are just starting. ..."
at this point we still can remove stuff ...
if we are sure that we stay in this structure we can go on to 1.x
I'd probably argue that we don't need to vendor any more - but I guess it depends on our lowest supported version of golang.
@zeripath
I dont like to go out of 0.x jet :https://medium.com/@aman.sardana/go-modules-versioning-dependency-management-d5f96b490774
“…version 0 is an exception for backward compatibility rule of golang as the version updated before version 1 can be backward incompatible. It is best for the libraries that are just starting. …”
at this point we still can remove stuff … if we are sure that we stay in this structure we can go on to 1.x
@6543 I will agree with @zeripath that we don't need vendor the dependencies on this library project.
[Add] VersionCheckto [WIP] [Add] VersionCheckFor performance reasons it would be better to request server version only once in
NewClient
@ -0,0 +9,4 @@
"github.com/hashicorp/go-version"
)
var serverVersion *version.Version
This should be moved into
Client
struct as fieldserverVersion string
@ -0,0 +12,4 @@
var serverVersion *version.Version
// ServerVersion returns the version of the server
func (c *Client) ServerVersion() (string, error) {
@ -36,3 +39,4 @@
accessToken: token,
client: &http.Client{},
}
if raw, err := c.ServerVersion(); err == nil {
Not needed here, load server version only when needed
@ -25,3 +27,4 @@
// Client represents a Gitea API client.
type Client struct {
url string
accessToken string
[WIP] [Add] VersionCheckto [Add] VersionCheck@lafriks can you review again?
@ -0,0 +20,4 @@
// CheckServerVersionConstraint validates that the login's server satisfies a
// given version constraint such as ">= 1.11.0+dev"
func (c *Client) CheckServerVersionConstraint(constraint string) error {
I think you should have a lock since there maybe multiple goroutines check the verions.
@lunny hope 9e722bb47272557c4aceb361dee8a4247743f8f1 is wat you want ...
Please resolve conflicts.
done
@lafriks are you ok as it is now?
@ -0,0 +22,4 @@
// given version constraint such as ">= 1.11.0+dev"
func (c *Client) CheckServerVersionConstraint(constraint string) (err error) {
setV := func() {
raw, _ := c.ServerVersion()
What if there is error?
raw = "" -> CheckServerVersionConstraint will always end with
return fmt.Errorf("gitea se...
You can use sync.RWMutex instead to be able to control behavior with errors better
@lafriks lunny like to prevent a race condition when somebody is doing this:
and so I used sync.Once ...
@lafriks sync.RWMutex is nice!
I name it neutral so it client.propertyLock can be used for altering any type of property
EDIT: outdated
Why not cache the version here?
I think we should also enable
-race
flag ongo test
.And a goroutine test is better.
@lunny enabled race
Ready to merge :)