Skip to content
This repository has been archived by the owner on May 11, 2019. It is now read-only.

Commit

Permalink
basic bzr + svn support (closes #2 and closes #3)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkulchenko committed Apr 26, 2015
1 parent c530d8a commit c85cd94
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
20 changes: 18 additions & 2 deletions packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func getPackageRootDir(repo string) (string, error) { // move backwards through

gitDir := path.Join(candidatePath, ".git")
hgDir := path.Join(candidatePath, ".hg")
bzrDir := path.Join(candidatePath, ".bzr")

if exists, _ := pathExists(gitDir); exists {
resultPath = candidatePath
Expand All @@ -48,6 +49,11 @@ func getPackageRootDir(repo string) (string, error) { // move backwards through
resultPath = candidatePath
break
}

if exists, _ := pathExists(bzrDir); exists {
resultPath = candidatePath
break
}
}

return resultPath, nil
Expand Down Expand Up @@ -120,6 +126,10 @@ func fetchPackage(repo string) error {
refreshCommand = []string{"git", "fetch", "--all"}
} else if exists, _ := pathExists(path.Join(packageDir, ".hg")); exists {
refreshCommand = []string{"hg", "pull"}
} else if exists, _ := pathExists(path.Join(packageDir, ".bzr")); exists {
refreshCommand = []string{"bzr", "pull"}
} else if exists, _ := pathExists(path.Join(packageDir, ".svn")); exists {
refreshCommand = []string{"svn", "up"}
}

if len(refreshCommand) > 0 {
Expand Down Expand Up @@ -296,9 +306,15 @@ func setPackageVersion(repo string, version string, humanVersion string) error {
checkoutCommand = []string{"git", "checkout", version}
} else if exists, _ := pathExists(".hg"); exists {
checkoutCommand = []string{"hg", "update", "-c", version}
} else if exists, _ := pathExists(".bzr"); exists {
if version != "" {
checkoutCommand = []string{"bzr", "update", "-r", version}
} else {
checkoutCommand = []string{"bzr", "update"}
}
} else {
if Verbose {
fmt.Printf(" - setting version of %s to %s (resolved as %s) ... %s\n", repo, humanVersion, version, color.GreenString("skipped, could not find repo type"))
fmt.Printf(" - setting version of %s to %s (resolved as %s) ... %s\n", repo, humanVersion, version, color.GreenString("skipped, unknown repo type"))
}
return nil
}
Expand Down Expand Up @@ -394,7 +410,7 @@ func checkPackageRecency(pack Package) (bool, PackageRecencyInfo, error) { // bo
} else if exists, _ := pathExists(".hg"); exists {
repoType = "hg"
} else {
return true, NilInfo, nil // if it's not git, force an update (improve this later)
return true, NilInfo, nil // force an update
}

var getVersionCommand, getHEADCommand, getUpstreamVersionCommand, getUpstreamDiffCommand, getInstalledDiffCommand []string
Expand Down
6 changes: 5 additions & 1 deletion versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ func getLatestVersionMatchingPattern(repo string, versionPattern string) (string
repoType = "git"
} else if exists, _ := pathExists(".hg"); exists {
repoType = "hg"
} else if exists, _ := pathExists(".bzr"); exists {
repoType = "bzr"
} else {
return versionPattern, nil
}
Expand All @@ -50,10 +52,12 @@ func getLatestVersionMatchingPattern(repo string, versionPattern string) (string
return "master", nil
} else if repoType == "hg" {
return "tip", nil
} else if repoType == "bzr" {
return "", nil
}
}

if repoType == "hg" {
if repoType == "hg" || repoType == "bzr" {
return versionPattern, nil
}

Expand Down

0 comments on commit c85cd94

Please sign in to comment.