|
4 | 4 | package template |
5 | 5 |
|
6 | 6 | import ( |
7 | | - "context" |
8 | 7 | "fmt" |
9 | 8 | "io" |
10 | 9 | "path" |
@@ -43,31 +42,31 @@ func Unmarshal(filename string, content []byte) (*api.IssueTemplate, error) { |
43 | 42 | } |
44 | 43 |
|
45 | 44 | // UnmarshalFromEntry parses out a valid template from the blob in entry |
46 | | -func UnmarshalFromEntry(ctx context.Context, entry *git.TreeEntry, dir string) (*api.IssueTemplate, error) { |
47 | | - return unmarshalFromEntry(ctx, entry, path.Join(dir, entry.Name())) // Filepaths in Git are ALWAYS '/' separated do not use filepath here |
| 45 | +func UnmarshalFromEntry(entry *git.TreeEntry, dir string) (*api.IssueTemplate, error) { |
| 46 | + return unmarshalFromEntry(entry, path.Join(dir, entry.Name())) // Filepaths in Git are ALWAYS '/' separated do not use filepath here |
48 | 47 | } |
49 | 48 |
|
50 | 49 | // UnmarshalFromCommit parses out a valid template from the commit |
51 | | -func UnmarshalFromCommit(ctx context.Context, commit *git.Commit, filename string) (*api.IssueTemplate, error) { |
| 50 | +func UnmarshalFromCommit(commit *git.Commit, filename string) (*api.IssueTemplate, error) { |
52 | 51 | entry, err := commit.GetTreeEntryByPath(filename) |
53 | 52 | if err != nil { |
54 | 53 | return nil, fmt.Errorf("get entry for %q: %w", filename, err) |
55 | 54 | } |
56 | | - return unmarshalFromEntry(ctx, entry, filename) |
| 55 | + return unmarshalFromEntry(entry, filename) |
57 | 56 | } |
58 | 57 |
|
59 | 58 | // UnmarshalFromRepo parses out a valid template from the head commit of the branch |
60 | | -func UnmarshalFromRepo(ctx context.Context, repo *git.Repository, branch, filename string) (*api.IssueTemplate, error) { |
| 59 | +func UnmarshalFromRepo(repo *git.Repository, branch, filename string) (*api.IssueTemplate, error) { |
61 | 60 | commit, err := repo.GetBranchCommit(branch) |
62 | 61 | if err != nil { |
63 | 62 | return nil, fmt.Errorf("get commit on branch %q: %w", branch, err) |
64 | 63 | } |
65 | 64 |
|
66 | | - return UnmarshalFromCommit(ctx, commit, filename) |
| 65 | + return UnmarshalFromCommit(commit, filename) |
67 | 66 | } |
68 | 67 |
|
69 | | -func unmarshalFromEntry(ctx context.Context, entry *git.TreeEntry, filename string) (*api.IssueTemplate, error) { |
70 | | - if size := entry.Blob().Size(); size > setting.Config().UI.MaxDisplayFileSize.Value(ctx) { |
| 68 | +func unmarshalFromEntry(entry *git.TreeEntry, filename string) (*api.IssueTemplate, error) { |
| 69 | + if size := entry.Blob().Size(); size > setting.UI.MaxDisplayFileSize { |
71 | 70 | return nil, fmt.Errorf("too large: %v > MaxDisplayFileSize", size) |
72 | 71 | } |
73 | 72 |
|
|
0 commit comments