-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10153 from b-camacho/lfs
git-lfs support
- Loading branch information
Showing
13 changed files
with
781 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
synopsis: "Git LFS support" | ||
prs: [10153] | ||
--- | ||
|
||
The Git fetcher now supports Large File Storage (LFS). This can be enabled by passing the attribute `lfs = true` to the fetcher, e.g. | ||
```console | ||
nix flake prefetch 'git+ssh://[email protected]/Apress/repo-with-large-file-storage.git?lfs=1' | ||
``` | ||
|
||
Author: [**@b-camacho**](https://github.com/b-camacho), [**@kip93**](https://github.com/kip93) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
#include <gtest/gtest.h> | ||
#include "fs-sink.hh" | ||
#include "serialise.hh" | ||
#include "git-lfs-fetch.hh" | ||
|
||
namespace nix { | ||
|
||
|
@@ -109,4 +110,131 @@ TEST_F(GitUtilsTest, sink_hardlink) | |
} | ||
}; | ||
|
||
namespace lfs { | ||
|
||
TEST_F(GitUtilsTest, parseGitRemoteUrl) | ||
{ | ||
{ | ||
GitUrl result = parseGitUrl("[email protected]:path/repo.git"); | ||
EXPECT_EQ(result.protocol, "ssh"); | ||
EXPECT_EQ(result.user, "git"); | ||
EXPECT_EQ(result.host, "example.com"); | ||
EXPECT_EQ(result.port, ""); | ||
EXPECT_EQ(result.path, "path/repo.git"); | ||
} | ||
|
||
{ | ||
GitUrl result = parseGitUrl("example.com:/path/repo.git"); | ||
EXPECT_EQ(result.protocol, "ssh"); | ||
EXPECT_EQ(result.user, ""); | ||
EXPECT_EQ(result.host, "example.com"); | ||
EXPECT_EQ(result.port, ""); | ||
EXPECT_EQ(result.path, "/path/repo.git"); | ||
} | ||
|
||
{ | ||
GitUrl result = parseGitUrl("example.com:path/repo.git"); | ||
EXPECT_EQ(result.protocol, "ssh"); | ||
EXPECT_EQ(result.user, ""); | ||
EXPECT_EQ(result.host, "example.com"); | ||
EXPECT_EQ(result.port, ""); | ||
EXPECT_EQ(result.path, "path/repo.git"); | ||
} | ||
|
||
{ | ||
GitUrl result = parseGitUrl("https://example.com/path/repo.git"); | ||
EXPECT_EQ(result.protocol, "https"); | ||
EXPECT_EQ(result.user, ""); | ||
EXPECT_EQ(result.host, "example.com"); | ||
EXPECT_EQ(result.port, ""); | ||
EXPECT_EQ(result.path, "path/repo.git"); | ||
} | ||
|
||
{ | ||
GitUrl result = parseGitUrl("ssh://[email protected]/path/repo.git"); | ||
EXPECT_EQ(result.protocol, "ssh"); | ||
EXPECT_EQ(result.user, "git"); | ||
EXPECT_EQ(result.host, "example.com"); | ||
EXPECT_EQ(result.port, ""); | ||
EXPECT_EQ(result.path, "path/repo.git"); | ||
} | ||
|
||
{ | ||
GitUrl result = parseGitUrl("ssh://example/path/repo.git"); | ||
EXPECT_EQ(result.protocol, "ssh"); | ||
EXPECT_EQ(result.user, ""); | ||
EXPECT_EQ(result.host, "example"); | ||
EXPECT_EQ(result.port, ""); | ||
EXPECT_EQ(result.path, "path/repo.git"); | ||
} | ||
|
||
{ | ||
GitUrl result = parseGitUrl("http://example.com:8080/path/repo.git"); | ||
EXPECT_EQ(result.protocol, "http"); | ||
EXPECT_EQ(result.user, ""); | ||
EXPECT_EQ(result.host, "example.com"); | ||
EXPECT_EQ(result.port, "8080"); | ||
EXPECT_EQ(result.path, "path/repo.git"); | ||
} | ||
|
||
{ | ||
GitUrl result = parseGitUrl("invalid-url"); | ||
EXPECT_EQ(result.protocol, ""); | ||
EXPECT_EQ(result.user, ""); | ||
EXPECT_EQ(result.host, ""); | ||
EXPECT_EQ(result.port, ""); | ||
EXPECT_EQ(result.path, ""); | ||
} | ||
|
||
{ | ||
GitUrl result = parseGitUrl(""); | ||
EXPECT_EQ(result.protocol, ""); | ||
EXPECT_EQ(result.user, ""); | ||
EXPECT_EQ(result.host, ""); | ||
EXPECT_EQ(result.port, ""); | ||
EXPECT_EQ(result.path, ""); | ||
} | ||
} | ||
TEST_F(GitUtilsTest, gitUrlToHttp) | ||
{ | ||
{ | ||
const GitUrl url = parseGitUrl("[email protected]:user/repo.git"); | ||
EXPECT_EQ(url.toHttp(), "https://github.com/user/repo.git"); | ||
} | ||
{ | ||
const GitUrl url = parseGitUrl("https://github.com/user/repo.git"); | ||
EXPECT_EQ(url.toHttp(), "https://github.com/user/repo.git"); | ||
} | ||
{ | ||
const GitUrl url = parseGitUrl("http://github.com/user/repo.git"); | ||
EXPECT_EQ(url.toHttp(), "http://github.com/user/repo.git"); | ||
} | ||
{ | ||
const GitUrl url = parseGitUrl("ssh://[email protected]:22/user/repo.git"); | ||
EXPECT_EQ(url.toHttp(), "https://github.com:22/user/repo.git"); | ||
} | ||
{ | ||
const GitUrl url = parseGitUrl("invalid-url"); | ||
EXPECT_EQ(url.toHttp(), ""); | ||
} | ||
} | ||
|
||
TEST_F(GitUtilsTest, gitUrlToSsh) | ||
{ | ||
{ | ||
const GitUrl url = parseGitUrl("https://example.com/user/repo.git"); | ||
const auto [host, path] = url.toSsh(); | ||
EXPECT_EQ(host, "example.com"); | ||
EXPECT_EQ(path, "user/repo.git"); | ||
} | ||
{ | ||
const GitUrl url = parseGitUrl("[email protected]:user/repo.git"); | ||
const auto [host, path] = url.toSsh(); | ||
EXPECT_EQ(host, "[email protected]"); | ||
EXPECT_EQ(path, "user/repo.git"); | ||
} | ||
} | ||
|
||
} // namespace lfs | ||
|
||
} // namespace nix |
Oops, something went wrong.