Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bzr.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ var bzrDetectURL = regexp.MustCompile("parent branch: (?P<foo>.+)\n")
// NewBzrRepo creates a new instance of BzrRepo. The remote and local directories
// need to be passed in.
func NewBzrRepo(remote, local string) (*BzrRepo, error) {
// Log deprecation warning
Logger.Println("WARNING: The Bazaar (bzr) project has been retired and is no longer maintained. Support for bzr may be removed in a future version.")

ins := depInstalled("bzr")
if !ins {
return nil, NewLocalError("bzr is not installed", nil, "")
Expand Down
34 changes: 33 additions & 1 deletion bzr_test.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,48 @@
package vcs

import (
"bytes"
"log"
"os"
"path/filepath"
"strings"
"testing"
"time"
//"log"
)

// Canary test to ensure BzrRepo implements the Repo interface.
var _ Repo = &BzrRepo{}

// TestBzrDeprecationWarning tests that a deprecation warning is logged when creating a BzrRepo
func TestBzrDeprecationWarning(t *testing.T) {
tempDir := t.TempDir()

// Create a custom logger to capture output
var buf bytes.Buffer
customLogger := log.New(&buf, "", 0)

// Save original logger and restore it after test
originalLogger := Logger
defer func() {
Logger = originalLogger
}()

// Set custom logger
Logger = customLogger

// Create a BzrRepo instance - this may fail if bzr is not installed,
// but the warning should still be logged before that check
_, _ = NewBzrRepo("https://launchpad.net/govcstestbzrrepo", tempDir+"/test")
// We don't check the error here because bzr might not be installed,
// but the warning should still be logged

// Check if deprecation warning was logged
output := buf.String()
if !strings.Contains(output, "WARNING: The Bazaar (bzr) project has been retired and is no longer maintained. Support for bzr may be removed in a future version.") {
t.Error("Expected WARNING in log output, got:", output)
}
}

// To verify bzr is working we perform integration testing
// with a known bzr service. Due to the long time of repeatedly checking out
// repos these tests are structured to work together.
Expand Down
Loading