github.com/glimps-jbo/go-licenses@v0.0.0-20230908151000-e06d3c113277/internal/third_party/pkgsite/source/source_patch.go (about) 1 // Copyright 2022 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package source 16 17 // This file includes all local additions to source package for google/go-licenses use-cases. 18 19 // SetCommit overrides commit to a specified commit. Usually, you should pass your version to 20 // ModuleInfo(). However, when you do not know the version and just wants a link that points to 21 // a known commit/branch/tag. You can use this method to directly override the commit like 22 // info.SetCommit("master"). 23 // 24 // Note this is different from directly passing "master" as version to ModuleInfo(), because for 25 // modules not at the root of a repo, there are conventions that add a module's relative dir in 26 // front of the version as the actual git tag. For example, for a sub module at ./submod whose 27 // version is v1.0.1, the actual git tag should be submod/v1.0.1. 28 func (i *Info) SetCommit(commit string) { 29 if i == nil { 30 return 31 } 32 i.commit = commit 33 }