File tree 2 files changed +27
-1
lines changed
2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,11 @@ func GetRawFile(ctx *context.APIContext) {
43
43
// description: filepath of the file to get
44
44
// type: string
45
45
// required: true
46
+ // - name: ref
47
+ // in: query
48
+ // description: "The name of the commit/branch/tag. Default the repository’s default branch (usually master)"
49
+ // type: string
50
+ // required: false
46
51
// responses:
47
52
// 200:
48
53
// description: success
@@ -54,7 +59,22 @@ func GetRawFile(ctx *context.APIContext) {
54
59
return
55
60
}
56
61
57
- blob , err := ctx .Repo .Commit .GetBlobByPath (ctx .Repo .TreePath )
62
+ commit := ctx .Repo .Commit
63
+
64
+ if ref := ctx .QueryTrim ("ref" ); len (ref ) > 0 {
65
+ var err error
66
+ commit , err = ctx .Repo .GitRepo .GetCommit (ref )
67
+ if err != nil {
68
+ if git .IsErrNotExist (err ) {
69
+ ctx .NotFound ()
70
+ } else {
71
+ ctx .Error (http .StatusInternalServerError , "GetBlobByPath" , err )
72
+ }
73
+ return
74
+ }
75
+ }
76
+
77
+ blob , err := commit .GetBlobByPath (ctx .Repo .TreePath )
58
78
if err != nil {
59
79
if git .IsErrNotExist (err ) {
60
80
ctx .NotFound ()
Original file line number Diff line number Diff line change 7845
7845
"name": "filepath",
7846
7846
"in": "path",
7847
7847
"required": true
7848
+ },
7849
+ {
7850
+ "type": "string",
7851
+ "description": "The name of the commit/branch/tag. Default the repository’s default branch (usually master)",
7852
+ "name": "ref",
7853
+ "in": "query"
7848
7854
}
7849
7855
],
7850
7856
"responses": {
You can’t perform that action at this time.
0 commit comments