Begin move to project/alias by unique ID
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package projects
|
||||
|
||||
import (
|
||||
"crypto/sha1"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -35,8 +36,7 @@ type ProjectLanguage struct {
|
||||
}
|
||||
|
||||
func NewProjectLanguages() *ProjectLanguages {
|
||||
var pLangs ProjectLanguages
|
||||
pLangs = make([]*ProjectLanguage, 0)
|
||||
var pLangs ProjectLanguages = make([]*ProjectLanguage, 0)
|
||||
return &pLangs
|
||||
}
|
||||
|
||||
@@ -44,6 +44,21 @@ func (pl *ProjectLanguages) AddLanguage(lang *ProjectLanguage) {
|
||||
*pl = append(*pl, lang)
|
||||
}
|
||||
|
||||
// Gets a unique ID using a short-sha of the http repo URL
|
||||
// along with the numerical ID of the project.
|
||||
// Uses SSH URL and then Remote if previous is empty
|
||||
func (p *Project) GetID() string {
|
||||
shaText := p.HTTPURLToRepo
|
||||
if shaText == "" && p.SSHURLToRepo != "" {
|
||||
shaText = p.SSHURLToRepo
|
||||
} else if shaText == "" {
|
||||
shaText = p.Remote
|
||||
}
|
||||
|
||||
shortSha := fmt.Sprintf("%x", sha1.Sum([]byte(shaText)))[:12]
|
||||
return fmt.Sprintf("%s||%d", shortSha, p.ID)
|
||||
}
|
||||
|
||||
func (p *Project) String() string {
|
||||
var projectString string
|
||||
if p != nil {
|
||||
|
||||
Reference in New Issue
Block a user