Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gitlab2github
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Recolic
gitlab2github
Commits
2c78d6dc
There was an error fetching the commit references. Please try again later.
Commit
2c78d6dc
authored
4 years ago
by
Bensong Liu
Browse files
Options
Downloads
Patches
Plain Diff
done.log done
parent
83db2787
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+3
-1
3 additions, 1 deletion
README.md
gitlab2github_sync.fish
+66
-0
66 additions, 0 deletions
gitlab2github_sync.fish
log
+0
-8
0 additions, 8 deletions
log
with
69 additions
and
9 deletions
README.md
+
3
−
1
View file @
2c78d6dc
...
...
@@ -4,5 +4,7 @@ This tool pull all public repo of some users FROM gitlab TO github.
Gitlab is the actual dev repo, and github is a mirror.
Dependencies: fish, jq, git
Dependencies: fish, json2table, git
This doesn't recursively resolve gitlab sub-group. Please specify every sub-group as a new namespace.
This diff is collapsed.
Click to expand it.
gitlab2github_sync.fish
+
66
−
0
View file @
2c78d6dc
#!/usr/bin/fish
set gitlab_host https://git.recolic.net
# set gitlab_namespace_src users/root groups/recolic-hust
set gitlab_namespace_src users/root
set github_user_dst "rtestgithubapi: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"
function echo2
echo $argv 1>&2
end
function sync_one_project
set project_name $argv[1]
set project_url $argv[2]
set github_project_desc "This is a read-only mirror for $project_url"
echo2 "Syncing $project_url to github:$github_user_dst..."
# Prepare github repository
set resp (curl -s -u $github_user_dst --data "{\"name\":\"$project_name\", \"description\":\"$github_project_desc\"}" https://api.github.com/user/repos)
if echo $resp | grep -F "name already exists on this account"
# Good. Update existing repo
else if echo $resp | grep -F $github_project_desc
echo2 "Creating new github repository success: $project_name"
else
echo2 "Failed to create or update github repo: $resp"
return 2
end
set github_username (echo $github_user_dst | sed 's/:.*$//g')
set github_project_url "https://$github_user_dst@github.com/$github_username/$project_name.git"
# Do the sync
test -d $project_name
or begin
git clone $project_url $project_name
and cd $project_name
and git remote add dst $github_project_url
and cd ..
or return 3
end
cd $project_name
# https://stackoverflow.com/questions/67054889/force-git-pull-to-resolve-divergent-by-discard-all-local-commits
and git fetch
and git reset --hard "@{upstream}"
and git push --tags --force dst (git branch --show-current)
and cd ..
or return 4
end
function do_namespace_copy
set ns_src $argv[1]
echo2 "Processing gitlab namespace $ns_src..."
set project_list (curl -s "$gitlab_host/api/v4/$ns_src/projects?per_page=9999" | json2table http_url_to_repo -p | grep VAL: | sed 's/^VAL: //g' | sed 's/|//g')
set workdir (pwd) # to avoid some failure in sync_one_project changes the workdir.
for project_url in $project_list
set project_name (echo "$project_url" | sed 's/.git$//g' | sed 's/^.*\///g')
sync_one_project $project_name $project_url
or echo2 "sync_one_project fails for $project_name with status=$status"
sleep 10
end
end
for ns in $gitlab_namespace_src
do_namespace_copy $ns
end
...
...
This diff is collapsed.
Click to expand it.
log
deleted
100644 → 0
+
0
−
8
View file @
83db2787
curl https://git.recolic.net/api/v4/users/root/projects
curl -u "rtestgithubapi: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" --data '{"name":"NEW_REPO_NAME"}' https://api.github.com/user/repos
curl -u "rtestgithubapi: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" --request PATCH --data '{"name":"NEW_REPO_NAME", "description":"a new description"}' https://api.github.com/repos/rtestgithubapi/NEW_REPO_NAME
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