Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita8b5eb7

Browse files
author
Hubot
committed
Sync changes from upstream repository
1 parent8844597 commita8b5eb7

File tree

3 files changed

+214
-12
lines changed

3 files changed

+214
-12
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title:Source Import API enhancements for working with Git LFS
3+
author_name:lizzhale
4+
---
5+
6+
Today we're introducing enhancements to the[Source Import API][docs] to support importing repositories with files larger than 100MB.
7+
8+
**Changes to parameters for starting an import**
9+
10+
[Starting an import][start-an-import] no longer requires a`vcs` parameter. Please be aware that without this parameter, the import job will take additional time to detect the vcs type before beginning the import. This detection step will be reflected in the response.
11+
12+
**New methods**
13+
14+
We've added 3 new methods that will enable API consumers to:
15+
16+
*[update][update-existing-import] the authentication or project choice for an import. If no parameters are provided during the request, the import will be restarted. Please note that this is a**breaking change**. Updating authentication for the originating URL is no longer supported through the[start an import][start-an-import] method. Please update your applications to use the new method.
17+
18+
*[set their preference][set-git-lfs-preference] for using Git LFS to import files larger than 100MB.
19+
20+
*[list all the files larger than 100MB][get-large-files] that were found during the import.
21+
22+
**New attributes for Git LFS**
23+
24+
Several new response attributes (`use_lfs`,`has_large_files`,`large_files_size`,`large_files`) were added to provide details regarding the large files found during the import. You can read more about the attributes[here][git-lfs-related-fields].
25+
26+
As before, to access the API during the preview period, you must provide a custom[media type][media-type] in the`Accept` header:
27+
28+
application/vnd.github.barred-rock-preview
29+
30+
For more information, see the[Source Import API documentation][docs], and if you have any questions or feedback, please[let us know][contact].
31+
32+
33+
[docs]:/v3/migration/source_imports/
34+
[start-an-import]:/v3/migration/source_imports/#start-an-import
35+
[update-existing-import]:/v3/migration/source_imports/#update-existing-import
36+
[set-git-lfs-preference]:/v3/migration/source_imports/#set-git-lfs-preference
37+
[get-large-files]:/v3/migration/source_imports/#get-large-files
38+
[git-lfs-related-fields]:/v3/migration/source_imports/#git-lfs-related-fields
39+
[media-type]:/v3/media
40+
[contact]:https://github.com/contact?form%5Bsubject%5D=Source+Import+API

‎content/v3/migration/source_imports.md

Lines changed: 115 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ This API is not currently available on GitHub Enterprise.
2626

2727
The Source Import API lets you start an import from a Git, Subversion, Mercurial, or Team Foundation Server source repository. This is the same functionality as[the GitHub Importer](https://import.github.com/).
2828

29-
A typical source import would[start the import](#start-an-import) and then (optionally)[update the authors](#map-a-commit-author). A more detailed example can be seen in this diagram:
29+
A typical source import would[start the import](#start-an-import) and then (optionally)[update the authors](#map-a-commit-author) and/or[set the preference](#set-git-lfs-preference) for using Git LFS if large files exist in the import. A more detailed example can be seen in this diagram:
3030

3131
```
3232
+---------+ +--------+ +---------------------+
@@ -78,6 +78,21 @@ A typical source import would [start the import](#start-an-import) and then (opt
7878
| | | |
7979
| |<-----+ |
8080
| | |
81+
| Get large files | |
82+
|----------------------------->| |
83+
| | |
84+
| opt_in to Git LFS | |
85+
|----------------------------->| |
86+
| | Rewrite commits for large files |
87+
| |------+ |
88+
| | | |
89+
| |<-----+ |
90+
| | |
91+
| | Update repository on GitHub |
92+
| |------+ |
93+
| | | |
94+
| |<-----+ |
95+
| | |
8196
| Get import progress | |
8297
|----------------------------->| |
8398
| "status": "complete" | |
@@ -96,8 +111,8 @@ Start a source import to a GitHub repository using GitHub Importer.
96111

97112
Name | Type | Description
98113
-----|------|--------------
99-
`vcs`|`string`|**Required** The originating VCS type. Can be one of "subversion", "git", "mercurial", or "tfvc".
100114
`vcs_url`|`url`|**Required** The URL of the originating repository.
115+
`vcs`|`string`|The originating VCS type. Can be one of`subversion`,`git`,`mercurial`, or`tfvc`. Please be aware that without this parameter, the import job will take additional time to detect the VCS type before beginning the import. This detection step will be reflected in the response.
101116
`vcs_username`|`string`|If authentication is required, the username to provide to`vcs_url`.
102117
`vcs_password`|`string`|If authentication is required, the password to provide to`vcs_url`.
103118
`tfvc_project`|`string`|For a tfvc import, the name of the project that is being imported.
@@ -121,7 +136,7 @@ Name | Type | Description
121136
View the progress of an import.
122137

123138
GET /repos/:owner/:repo/import
124-
139+
125140
###Response
126141

127142
<%= headers 200 %>
@@ -133,23 +148,77 @@ This section includes details about the possible values of the `status` field of
133148

134149
An import that does not have errors will progress through these steps:
135150

151+
*`detecting` - the "detection" step of the import is in progress because the request did not include a`vcs` parameter. The import is identifying the type of source control present at the URL.
136152
*`importing` - the "raw" step of the import is in progress. This is where commit data is fetched from the original repository. The import progress response will include`commit_count` (the total number of raw commits that will be imported) and`percent` (0 - 100, the current progress through the import).
137153
*`mapping` - the "rewrite" step of the import is in progress. This is where SVN branches are converted to Git branches, and where author updates are applied. The import progress response does not include progress information.
138154
*`pushing` - the "push" step of the import is in progress. This is where the importer updates the repository on GitHub. The import progress response will include`push_percent`, which is the percent value reported by`git push` when it is "Writing objects".
139155
*`complete` - the import is complete, and the repository is ready on GitHub.
140156

141157
If there are problems, you will see one of these in the`status` field:
142158

143-
*`auth_failed` - the import requires authentication in order to connect to the original repository. Makeanother "Start Import" request, and include`vcs_username` and`vcs_password`.
159+
*`auth_failed` - the import requires authentication in order to connect to the original repository. Makean "Update Existing Import" request, and include`vcs_username` and`vcs_password`.
144160
*`error` - the import encountered an error. The import progress response will include the`failed_step` and an error message.[Contact support](https://github.com/contact?form%5Bsubject%5D=Source+Import+API+error) for more information.
161+
*`detection_needs_auth` - the importer requires authentication for the originating repository to continue detection. Make an "Update Existing Import" request, and include`vcs_username` and`vcs_password`.
162+
*`detection_found_nothing` - the importer didn't recognize any source control at the URL.
163+
*`detection_found_multiple` - the importer found several projects or repositories at the provided URL. When this is the case, the Import Progress response will also include a`project_choices` field with the possible project choices as values. Make an "Update Existing Import" request, and include`vcs` and (if applicable)`tfvc_project`.
164+
165+
###Git LFS related fields
166+
167+
This section includes details about Git LFS related fields that may be present in the Import Progress response.
168+
169+
*`use_lfs` - describes whether the import has been opted in or out of using Git LFS. The value can be`opt_in`,`opt_out`, or`undecided` if no action has been taken.
170+
*`has_large_files` - the boolean value describing whether files larger than 100MB were found during the`importing` step.
171+
*`large_files_size` - the total size in gigabytes of files larger than 100MB found in the originating repository.
172+
*`large_files_count` - the total number of of files larger than 100MB found in the originating repository. To see a list of these files, make a "Get Large Files" request.
173+
174+
##Update existing import
175+
176+
An import can be updated with credentials or a`project_choice` by passing in the appropriate parameters in this API request. If no parameters are provided, the import will be restarted.
177+
178+
PATCH /repos/:owner/:repo/import
179+
180+
###Response
181+
182+
<%= headers 200,:Location => "https://api.github.com/repos/spraints/socm/import" %>
183+
<%= json:source_import %>
184+
185+
###Parameters for updating authentication
186+
187+
Name | Type | Description
188+
-----|------|--------------
189+
`vcs_username`|`string`|The username to provide to the originating repository.
190+
`vcs_password`|`string`|The password to provide to the originating repository.
191+
192+
###Example
193+
194+
<%= json\
195+
:vcs_username => "octocat",
196+
:vcs_password => "secret"
197+
%>
198+
199+
###Response
200+
201+
<%= headers 200 %>
202+
<%= json:source_import_update_auth %>
145203

146-
If you query import statusforan import started via the web UI, you may also see these states:
204+
###Parametersforupdating project choice
147205

148-
*`detecting` - you've entered a URL via the web UI, and the importer is figuring out what type of source control is present at the URL.
149-
*`detection_needs_auth` - you've entered a URL via the web UI, and the importer needs you to enter authentication credentials in the web UI in order to continue detection.
150-
*`detection_found_nothing` - the importer didn't recognize any source control at the URL entered via the web UI.
151-
*`detection_found_multiple` - the importer found several projects or repositories at the provided URL.
152-
*`waiting_to_push` - the raw and rewrite steps are complete, but a destination GitHub repository hasn't been created yet.
206+
Name | Type | Description
207+
-----|------|--------------
208+
`vcs`|`string`|The chosen project's VCS type.
209+
`tfvc_project`|`string`|For a tfvc import, the name of the project that is being imported.
210+
211+
###Example
212+
213+
<%= json\
214+
:vcs => "tfvc",
215+
:tfvc_project => "project"
216+
%>
217+
218+
###Response
219+
220+
<%= headers 200 %>
221+
<%= json:source_import_update_project_choice %>
153222

154223
##Get commit authors
155224

@@ -158,7 +227,7 @@ Each type of source control system represents authors in a different way. For ex
158227
This API method and the "Map a commit author" method allow you to provide correct Git author information.
159228

160229
GET /repos/:owner/:repo/import/authors
161-
230+
162231
###Parameters
163232

164233
Name | Type | Description
@@ -175,7 +244,7 @@ Name | Type | Description
175244
Update an author's identity for the import. Your application can continue updating authors any time before you push new commits to the repository.
176245

177246
PATCH /repos/:owner/:repo/import/authors/:author_id
178-
247+
179248
###Parameters
180249

181250
Name | Type | Description
@@ -195,6 +264,40 @@ Name | Type | Description
195264
<%= headers 200 %>
196265
<%= json:source_import_author %>
197266

267+
##Set Git LFS preference
268+
269+
You can import repositories from Subversion, Mercurial, and TFS that include files larger than 100MB. This ability is powered by[Git LFS](https://git-lfs.github.com). You can learn more about our LFS feature and working with large files[on our help site](https://help.github.com/articles/versioning-large-files/).
270+
271+
PATCH /:owner/:name/import/lfs
272+
273+
###Parameters
274+
275+
Name | Type | Description
276+
-----|------|--------------
277+
`use_lfs`|`string`|**Required** Can be one of`opt_in` (large files will be stored using Git LFS) or`opt_out` (large files will be removed during the import).
278+
279+
###Example
280+
281+
<%= json\
282+
:use_lfs => "opt_in"
283+
%>
284+
285+
###Response
286+
287+
<%= headers 200 %>
288+
<%= json:source_import_complete %>
289+
290+
##Get large files
291+
292+
List files larger than 100MB found during the import
293+
294+
GET /:owner/:name/import/large_files
295+
296+
###Response
297+
298+
<%= headers 200 %>
299+
<%= json:source_import_large_files %>
300+
198301
##Cancel an import
199302

200303
Stop an import for a repository.

‎lib/responses/source_imports.rb

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ module Resources
44
moduleResponses
55
SOURCE_IMPORT ||={
66
"vcs"=>"subversion",
7+
"use_lfs"=>"undecided",
78
"vcs_url"=>"http://svn.mycompany.com/svn/myproject",
89
"status"=>"importing",
910
"status_text"=>"Importing...",
11+
"has_large_files"=>false,
12+
"large_files_size"=>0,
13+
"large_files_count"=>0,
1014
"authors_count"=>0,
1115
"percent"=>42,
1216
"commit_count"=>1042,
@@ -18,16 +22,50 @@ module Responses
1822

1923
SOURCE_IMPORT_COMPLETE ||={
2024
"vcs"=>"subversion",
25+
"use_lfs"=>"opt_in",
2126
"vcs_url"=>"http://svn.mycompany.com/svn/myproject",
2227
"status"=>"complete",
2328
"status_text"=>"Done",
29+
"has_large_files"=>true,
30+
"large_files_size"=>132331036,
31+
"large_files_count"=>1,
2432
"authors_count"=>4,
2533
"url"=>"https://api.github.com/repos/octocat/socm/import",
2634
"html_url"=>"https://import.github.com/octocat/socm/import",
2735
"authors_url"=>"https://api.github.com/repos/octocat/socm/import/authors",
2836
"repository_url"=>"https://api.github.com/repos/octocat/socm"
2937
}
3038

39+
SOURCE_IMPORT_UPDATE_AUTH ||={
40+
"vcs":"subversion",
41+
"use_lfs":"undecided",
42+
"vcs_url":"http://svn.mycompany.com/svn/myproject",
43+
"status":"detecting",
44+
"url"=>"https://api.github.com/repos/octocat/socm/import",
45+
"html_url"=>"https://import.github.com/octocat/socm/import",
46+
"authors_url"=>"https://api.github.com/repos/octocat/socm/import/authors",
47+
"repository_url"=>"https://api.github.com/repos/octocat/socm"
48+
}
49+
50+
SOURCE_IMPORT_UPDATE_PROJECT_CHOICE ||={
51+
"vcs"=>"tfvc",
52+
"use_lfs":"undecided",
53+
"vcs_url"=>"http://tfs.mycompany.com/tfs/myproject",
54+
"tfvc_project":"project",
55+
"status"=>"importing",
56+
"status_text"=>"Importing...",
57+
"has_large_files"=>false,
58+
"large_files_size"=>0,
59+
"large_files_count"=>0,
60+
"authors_count"=>0,
61+
"percent"=>42,
62+
"commit_count"=>1042,
63+
"url"=>"https://api.github.com/repos/octocat/socm/import",
64+
"html_url"=>"https://import.github.com/octocat/socm/import",
65+
"authors_url"=>"https://api.github.com/repos/octocat/socm/import/authors",
66+
"repository_url"=>"https://api.github.com/repos/octocat/socm"
67+
}
68+
3169
SOURCE_IMPORT_AUTHOR ||={
3270
"id"=>2268557,
3371
"remote_id"=>"nobody@fc7da526-431c-80fe-3c8c-c148ff18d7ef",
@@ -59,6 +97,27 @@ module Responses
5997
"import_url"=>"https://api.github.com/repos/octocat/socm/import"
6098
}
6199
]
100+
101+
SOURCE_IMPORT_LARGE_FILES ||=[
102+
{
103+
"ref_name":"refs/heads/master",
104+
"path":"foo/bar/1",
105+
"oid":"d3d9446802a44259755d38e6d163e820",
106+
"size":10485760
107+
},
108+
{
109+
"ref_name":"refs/heads/master",
110+
"path":"foo/bar/2",
111+
"oid":"6512bd43d9caa6e02c990b0a82652dca",
112+
"size":11534336
113+
},
114+
{
115+
"ref_name":"refs/heads/master",
116+
"path":"foo/bar/3",
117+
"oid":"c20ad4d76fe97759aa27a0c99bff6710",
118+
"size":12582912
119+
}
120+
]
62121
end
63122
end
64123
end

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp