Skip to content

Commit

Permalink
✨ KAI support. (#64)
Browse files Browse the repository at this point in the history
Add support for fetch the `head` commit.

---------

Signed-off-by: Jeff Ortel <jortel@redhat.com>
  • Loading branch information
jortel authored Aug 13, 2024
1 parent 964583d commit f117cd5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions repository/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type SCM interface {
Fetch() (err error)
Branch(name string) (err error)
Commit(files []string, msg string) (err error)
Head() (commit string, err error)
}

// Remote repository.
Expand Down
15 changes: 15 additions & 0 deletions repository/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,21 @@ func (r *Git) Commit(files []string, msg string) (err error) {
return r.push()
}

// Head returns HEAD commit.
func (r *Git) Head() (commit string, err error) {
cmd := command.New("/usr/bin/git")
cmd.Dir = r.Path
cmd.Options.Add("rev-parse")
cmd.Options.Add("HEAD")
err = cmd.Run()
if err != nil {
return
}
commit = string(cmd.Output())
commit = strings.TrimSpace(commit)
return
}

// push changes to remote.
func (r *Git) push() (err error) {
cmd := command.New("/usr/bin/git")
Expand Down
6 changes: 6 additions & 0 deletions repository/subversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ func (r *Subversion) Commit(files []string, msg string) (err error) {
return
}

// Head returns latest commit.
func (r *Subversion) Head() (commit string, err error) {
// TODO: needs implementation.
return
}

// URL returns the parsed URL.
func (r *Subversion) URL() (u *urllib.URL) {
u, _ = urllib.Parse(r.Remote.URL)
Expand Down

0 comments on commit f117cd5

Please sign in to comment.