diff options
author | Daniel Smith <daniel.smith@qt.io> | 2020-09-24 10:46:56 +0200 |
---|---|---|
committer | Daniel Smith <daniel.smith@qt.io> | 2020-09-29 13:34:05 +0200 |
commit | 31776af0ba02639fed37c6441b093977f13c8fd0 (patch) | |
tree | 9febd11be3a2f5b9e6d234dce0e6a3c920b17874 /src | |
parent | 78d37bb5942b13922bce2ca42c042ad335ac475a (diff) | |
download | qtqa-31776af0ba02639fed37c6441b093977f13c8fd0.tar.gz |
Submodule update bot: Allow manual selection of qtbase sha
It's possible that when starting a new round, it may be desirable
to select a specific qtbase integration sha, instead of HEAD.
This typically occurs when a submodule update round has trouble
moving forward because too many breaking changes have been applied
to qtbase.
This change allows manual section of a valid sha to serve as the
starting point for a new round.
New environment variables:
Set CUSTOM_QTBASE to select a custom qtbase without user input.
Set AUTORUN to choose qtbase/head without user input.
If neither is set, user input is required to input a sha or
accept the current head.
Change-Id: Ice633151e06797749028c9e06073563b137548d8
Reviewed-by: Toni Saario <toni.saario@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/qtmoduleupdater/module.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/qtmoduleupdater/module.go b/src/qtmoduleupdater/module.go index a335028..99244d0 100644 --- a/src/qtmoduleupdater/module.go +++ b/src/qtmoduleupdater/module.go @@ -31,7 +31,9 @@ import ( "bytes" "fmt" "log" + "os" "path/filepath" + "regexp" "sort" "strings" @@ -63,6 +65,8 @@ type YAMLDependencies struct { Dependencies YAMLDependenciesMap `yaml:"dependencies"` } +var shaValidator = regexp.MustCompile(`\b[0-9a-f]{40}\b`) + // MarshalYAML implements the marshalling of the dependencies while // making sure the entries are sorted. func (depMap *YAMLDependenciesMap) MarshalYAML() (interface{}, error) { @@ -193,6 +197,39 @@ func NewModule(moduleName string, branch string, qt5Modules map[string]*submodul return nil, fmt.Errorf("could not fetch repo tip %s of %s: %s", headRef, moduleName, err) } + var sha string + + if repoPath == "qt/qtbase" { + fmt.Printf("\nProposing to update %s to %s. You may now override this sha if desired.\n", repoPath, moduleTipCommit) + fmt.Print("WARN: Overriding shas may cause an inconsistent set. Only do this if you know what you're doing.\n") + for { + if os.Getenv("CUSTOM_QTBASE") != "" { + sha = os.Getenv("CUSTOM_QTBASE") + fmt.Printf("Using custom Qtbase SHA from environment variable CUSTOM_QTBASE: %s\n", sha) + fmt.Println("NOTICE: No sha validation occurs on input from environment variables.") + moduleTipCommit = OID(strings.Trim(sha, " ")) + break + } else if os.Getenv("AUTORUN") == "" { + fmt.Print("\nPress Return to accept default proposal or enter a custom sha:\n->") + fmt.Scanln(&sha) + } + if sha != "" { + sha = strings.Trim(sha, " ") + if shaValidator.MatchString(sha) { + moduleTipCommit = OID(sha) + fmt.Printf("Using custom sha for %s: %s\n", repoPath, moduleTipCommit) + break + } else { + fmt.Printf("Custom sha \"%s\" is not a valid SHA1. Try again or accept the default.\n", sha) + sha = "" + } + } else { + fmt.Printf("Using default HEAD sha for %s: %s", repoPath, moduleTipCommit) + break + } + } + } + yamlDependencies := &YAMLDependencies{} yamlDependencies.Dependencies = make(map[string]*YAMLModule) |