Skip to content

Commit ee04150

Browse files
committed
Add the lfs related fixes from feature/storage branch
1 parent 1d059cf commit ee04150

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
build
1+
build
2+
.DS_Store

cmd/git-remote-gitopia/gitopia.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ func (h *GitopiaHandler) Initialize(remote *core.Remote) error {
9898

9999
h.remoteRepository = *res.Repository
100100

101+
// Configure LFS URL for clone operations to avoid SSH to non-existent "gitopia" hostname
102+
lfsURL := fmt.Sprintf("%v/%v.git", config.GitServerHost, h.remoteRepository.Id)
103+
cmd := core.GitCommand("git", "config", "--local", "lfs.url", lfsURL)
104+
if err := cmd.Run(); err != nil {
105+
// Log but don't fail if LFS config fails (repo might not have LFS)
106+
remote.Logger.Printf("Warning: could not configure LFS URL: %v", err)
107+
}
108+
101109
return nil
102110
}
103111

@@ -139,9 +147,11 @@ func (h *GitopiaHandler) List(remote *core.Remote, forPush bool) ([]string, erro
139147

140148
func (h *GitopiaHandler) Fetch(remote *core.Remote, refsToFetch []core.RefToFetch) error {
141149
remoteURL := fmt.Sprintf("%v/%v.git", config.GitServerHost, h.remoteRepository.Id)
150+
lfsURL := remoteURL // Use same URL for LFS
142151

143152
if !remote.Force {
144153
args := []string{
154+
"-c", fmt.Sprintf("lfs.url=%s", lfsURL),
145155
"fetch",
146156
"--no-write-fetch-head",
147157
remoteURL,
@@ -165,6 +175,7 @@ func (h *GitopiaHandler) Fetch(remote *core.Remote, refsToFetch []core.RefToFetc
165175
}
166176

167177
args := []string{
178+
"-c", fmt.Sprintf("lfs.url=%s", lfsURL),
168179
"fetch",
169180
"--no-write-fetch-head",
170181
remoteURL,
@@ -215,6 +226,7 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush)
215226
}
216227

217228
remoteURL := fmt.Sprintf("%v/%v.git", config.GitServerHost, h.remoteRepository.Id)
229+
lfsURL := remoteURL // Use same URL for LFS
218230

219231
var newRemoteRefSha string
220232
var setBranches []gitopiatypes.MsgMultiSetBranch_Branch
@@ -267,6 +279,8 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush)
267279
"credential.helper=",
268280
"-c",
269281
"credential.helper=gitopia",
282+
"-c",
283+
fmt.Sprintf("lfs.url=%s", lfsURL),
270284
"push",
271285
remoteURL,
272286
fmt.Sprintf("%s:%s", ref.Local, ref.Remote),

0 commit comments

Comments
 (0)