25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 

80 satır
2.3 KiB

  1. // Copyright 2019 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // Package version records versioning information about this module.
  5. package version
  6. import (
  7. "fmt"
  8. "strings"
  9. )
  10. // These constants determine the current version of this module.
  11. //
  12. // For our release process, we enforce the following rules:
  13. // - Tagged releases use a tag that is identical to String.
  14. // - Tagged releases never reference a commit where the String
  15. // contains "devel".
  16. // - The set of all commits in this repository where String
  17. // does not contain "devel" must have a unique String.
  18. //
  19. // Steps for tagging a new release:
  20. //
  21. // 1. Create a new CL.
  22. //
  23. // 2. Update Minor, Patch, and/or PreRelease as necessary.
  24. // PreRelease must not contain the string "devel".
  25. //
  26. // 3. Since the last released minor version, have there been any changes to
  27. // generator that relies on new functionality in the runtime?
  28. // If yes, then increment RequiredGenerated.
  29. //
  30. // 4. Since the last released minor version, have there been any changes to
  31. // the runtime that removes support for old .pb.go source code?
  32. // If yes, then increment SupportMinimum.
  33. //
  34. // 5. Send out the CL for review and submit it.
  35. // Note that the next CL in step 8 must be submitted after this CL
  36. // without any other CLs in-between.
  37. //
  38. // 6. Tag a new version, where the tag is is the current String.
  39. //
  40. // 7. Write release notes for all notable changes
  41. // between this release and the last release.
  42. //
  43. // 8. Create a new CL.
  44. //
  45. // 9. Update PreRelease to include the string "devel".
  46. // For example: "" -> "devel" or "rc.1" -> "rc.1.devel"
  47. //
  48. // 10. Send out the CL for review and submit it.
  49. const (
  50. Major = 1
  51. Minor = 30
  52. Patch = 0
  53. PreRelease = ""
  54. )
  55. // String formats the version string for this module in semver format.
  56. //
  57. // Examples:
  58. //
  59. // v1.20.1
  60. // v1.21.0-rc.1
  61. func String() string {
  62. v := fmt.Sprintf("v%d.%d.%d", Major, Minor, Patch)
  63. if PreRelease != "" {
  64. v += "-" + PreRelease
  65. // TODO: Add metadata about the commit or build hash.
  66. // See https://golang.org/issue/29814
  67. // See https://golang.org/issue/33533
  68. var metadata string
  69. if strings.Contains(PreRelease, "devel") && metadata != "" {
  70. v += "+" + metadata
  71. }
  72. }
  73. return v
  74. }