Skip to content

Commit

Permalink
:sparkes: implement Subversion.Head().
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Ortel <jortel@redhat.com>
  • Loading branch information
jortel committed Nov 22, 2024
1 parent a87f4c3 commit 3f702c6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
21 changes: 19 additions & 2 deletions repository/subversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
urllib "net/url"
"os"
pathlib "path"
"regexp"
"strings"

liberr "github.com/jortel/go-utils/error"
Expand All @@ -16,6 +17,9 @@ import (
"github.com/konveyor/tackle2-hub/nas"
)

// RevisionRegex match revision embedded in `svn info`.
var RevisionRegex = regexp.MustCompile(`(Revision\:\s+)([\d]+)`)

// Subversion repository.
type Subversion struct {
Authenticated
Expand Down Expand Up @@ -115,9 +119,22 @@ func (r *Subversion) Commit(files []string, msg string) (err error) {
return
}

// Head returns latest commit.
// Head returns the current revision.
func (r *Subversion) Head() (commit string, err error) {
// TODO: needs implementation.
cmd := r.svn()
cmd.Dir = r.root()
cmd.Options.Add("info", "-r", "HEAD")
err = cmd.Run()
if err != nil {
return
}
output := cmd.Output()
m := RevisionRegex.FindStringSubmatch(string(output))
if len(m) == 3 {
commit = m[2]
} else {
err = liberr.New("[SVN] info parser failed.")
}
return
}

Expand Down
15 changes: 0 additions & 15 deletions repository/svn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,3 @@ func TestSvnURL(t *testing.T) {
expectStr := "http://svn.corp/project/trunk/eng/product/thing/app_1"
g.Expect(expectStr).To(gomega.Equal(s))
}

func TestSvnFetch(t *testing.T) {
//g := gomega.NewGomegaWithT(t)
remote := Remote{
URL: "http://svn.corp/project",
Branch: "trunk",
Path: "eng/product/thing/app_1",
}
// Load.
r := Subversion{
Remote: remote,
Path: "/tmp/svn/test",
}
r.checkout()
}

0 comments on commit 3f702c6

Please sign in to comment.