Always use commit and originUrl from the git repository

Previously users were able to override commit and originUrl
in the config, this was never intended.
This commit is contained in:
Denis Bilenko 2024-11-27 21:21:16 +01:00
parent 6fc2093a22
commit 7243eda92e
1 changed files with 5 additions and 13 deletions

View File

@ -40,20 +40,12 @@ func (m *loadGitDetails) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagn
log.Warnf(ctx, "failed to load current branch: %s", err)
}
// load commit hash if undefined
if b.Config.Bundle.Git.Commit == "" {
commit, err := repo.LatestCommit()
if err != nil {
log.Warnf(ctx, "failed to load latest commit: %s", err)
} else {
b.Config.Bundle.Git.Commit = commit
}
}
// load origin url if undefined
if b.Config.Bundle.Git.OriginURL == "" {
remoteUrl := repo.OriginUrl()
b.Config.Bundle.Git.OriginURL = remoteUrl
commit, err := repo.LatestCommit()
if err != nil {
log.Warnf(ctx, "failed to load latest commit: %s", err)
}
b.Config.Bundle.Git.Commit = commit
b.Config.Bundle.Git.OriginURL = repo.OriginUrl()
// Compute relative path of the bundle root from the Git repo root.
absBundlePath, err := filepath.Abs(b.BundleRootPath)