Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
gh_fetch
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nimrod
gh_fetch
Commits
f082cd0d
Unverified
Commit
f082cd0d
authored
5 years ago
by
Srdjan Grubor
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #16 from endlessm/fixes-for-upstream
Fixes for upstream
parents
51f20050
cbbcebc8
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
update_repos
+20
-7
20 additions, 7 deletions
update_repos
with
20 additions
and
7 deletions
update_repos
+
20
−
7
View file @
f082cd0d
#!/usr/bin/python
# encoding: utf-8
import
base64
import
sys
import
os
import
argparse
from
collections
import
namedtuple
from
subprocess
import
Popen
,
PIPE
from
urllib2
import
urlopen
from
urllib
import
urlencode
from
urllib2
import
Request
,
urlopen
import
json
from
urlparse
import
urlparse
...
...
@@ -15,14 +17,14 @@ WHITELIST=[]
BLACKLIST
=
[]
LISTINGS_PER_PAGE
=
100
ACCESS_TOKEN_PARAM
=
'
?access_token=%s
'
LISTING_PAGE_PARAM
=
'
&per_page=%d&page=%d
'
LISTINGS_PER_PAGE_PARAM
=
'
per_page
'
LISTING_PAGE_PARAM
=
'
page
'
GITHUB_API_HOST
=
'
https://api.github.com
'
GIT_CLONE_CMD
=
'
git clone %s %s %s
'
GIT_CLONE_API_URL
=
'
https://%s@github.com/%s
'
GIT_SHA_CMD
=
'
git rev-parse --short %s
'
GIT_FETCH_CMD
=
'
git fetch
'
GIT_FETCH_CMD
=
'
git fetch
--tags
'
GIT_CHECK_REMOTE_CMD
=
'
git ls-remote
'
USER_DETAILS_PATH
=
'
/users/%s
'
...
...
@@ -73,12 +75,23 @@ class AttributeDict(dict):
self
[
attr
]
=
value
def
read_api_uri
(
uri
,
config
,
page
=
1
):
uri
+=
ACCESS_TOKEN_PARAM
%
config
.
token
+
LISTING_PAGE_PARAM
%
(
LISTINGS_PER_PAGE
,
page
)
params
=
{
LISTINGS_PER_PAGE_PARAM
:
LISTINGS_PER_PAGE
,
LISTING_PAGE_PARAM
:
page
,
}
uri
+=
'
?
'
+
urlencode
(
params
)
creds
=
base64
.
b64encode
(
config
.
token
.
encode
(
'
utf-8
'
)).
decode
(
'
ascii
'
)
basic_auth
=
'
Basic {}
'
.
format
(
creds
)
headers
=
{
'
Authorization
'
:
basic_auth
,
}
if
config
.
debug
:
print
"
Trying
:
"
,
uri
print
"
Trying
URI {} with headers {}
"
.
format
(
uri
,
headers
)
return
urlopen
(
uri
).
read
()
req
=
Request
(
uri
,
headers
=
headers
)
return
urlopen
(
req
).
read
()
def
get_json
(
uri
,
config
,
obj_type
=
AttributeDict
,
page
=
1
):
return
json
.
loads
(
read_api_uri
(
uri
,
config
,
page
),
object_hook
=
obj_type
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment