You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
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].
@@ -26,7 +26,7 @@ This API is not currently available on GitHub Enterprise.
26
26
27
27
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/).
28
28
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:
30
30
31
31
```
32
32
+---------+ +--------+ +---------------------+
@@ -78,6 +78,21 @@ A typical source import would [start the import](#start-an-import) and then (opt
78
78
| | | |
79
79
| |<-----+ |
80
80
| | |
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
+
| | |
81
96
| Get import progress | |
82
97
|----------------------------->| |
83
98
| "status": "complete" | |
@@ -96,8 +111,8 @@ Start a source import to a GitHub repository using GitHub Importer.
96
111
97
112
Name | Type | Description
98
113
-----|------|--------------
99
-
`vcs`|`string`|**Required** The originating VCS type. Can be one of "subversion", "git", "mercurial", or "tfvc".
100
114
`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.
101
116
`vcs_username`|`string`|If authentication is required, the username to provide to`vcs_url`.
102
117
`vcs_password`|`string`|If authentication is required, the password to provide to`vcs_url`.
103
118
`tfvc_project`|`string`|For a tfvc import, the name of the project that is being imported.
@@ -121,7 +136,7 @@ Name | Type | Description
121
136
View the progress of an import.
122
137
123
138
GET /repos/:owner/:repo/import
124
-
139
+
125
140
###Response
126
141
127
142
<%= headers 200 %>
@@ -133,23 +148,77 @@ This section includes details about the possible values of the `status` field of
133
148
134
149
An import that does not have errors will progress through these steps:
135
150
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.
136
152
*`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).
137
153
*`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.
138
154
*`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".
139
155
*`complete` - the import is complete, and the repository is ready on GitHub.
140
156
141
157
If there are problems, you will see one of these in the`status` field:
142
158
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`.
144
160
*`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.
`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 %>
145
203
146
-
If you query import statusforan import started via the web UI, you may also see these states:
204
+
###Parametersforupdating project choice
147
205
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 %>
153
222
154
223
##Get commit authors
155
224
@@ -158,7 +227,7 @@ Each type of source control system represents authors in a different way. For ex
158
227
This API method and the "Map a commit author" method allow you to provide correct Git author information.
159
228
160
229
GET /repos/:owner/:repo/import/authors
161
-
230
+
162
231
###Parameters
163
232
164
233
Name | Type | Description
@@ -175,7 +244,7 @@ Name | Type | Description
175
244
Update an author's identity for the import. Your application can continue updating authors any time before you push new commits to the repository.
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