मेरे पास नीचे के रूप में कमांड के साथ कर्ल प्रतिक्रिया से एक सामान्य संगठन रेपो सूची है:
curl "https://api.github.com/orgs/[organization]/repos?access_token=[access_token]"
इस कमांड का आउटपुट बहुत बड़ा है। मैं प्रत्येक रेपो के clone_url
पैरामीटर को निकालना चाहता हूं , उन यूआरएल पर लूप करना और git clone
उस पर चलना ।
नीचे tha JSON
आउटपुट की एक प्रविष्टि की झलक curl
मुझे दी गई है:
[
{
"id": 42059877,
"name": "customrepo",
"full_name": "SampleOrg/customrepo",
"owner": {
"login": "SampleOrg",
"id": 14164701,
"avatar_url": "https://avatars1.githubusercontent.com/u/14164701?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/SampleOrg",
"html_url": "https://github.com/SampleOrg",
"followers_url": "https://api.github.com/users/SampleOrg/followers",
"following_url": "https://api.github.com/users/SampleOrg/following{/other_user}",
"gists_url": "https://api.github.com/users/SampleOrg/gists{/gist_id}",
"starred_url": "https://api.github.com/users/SampleOrg/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/SampleOrg/subscriptions",
"organizations_url": "https://api.github.com/users/SampleOrg/orgs",
"repos_url": "https://api.github.com/users/SampleOrg/repos",
"events_url": "https://api.github.com/users/SampleOrg/events{/privacy}",
"received_events_url": "https://api.github.com/users/SampleOrg/received_events",
"type": "Organization",
"site_admin": false
},
"private": true,
"html_url": "https://github.com/SampleOrg/customrepo",
"description": null,
"fork": false,
"url": "https://api.github.com/repos/SampleOrg/customrepo",
"forks_url": "https://api.github.com/repos/SampleOrg/customrepo/forks",
"keys_url": "https://api.github.com/repos/SampleOrg/customrepo/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/SampleOrg/customrepo/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/SampleOrg/customrepo/teams",
"hooks_url": "https://api.github.com/repos/SampleOrg/customrepo/hooks",
"issue_events_url": "https://api.github.com/repos/SampleOrg/customrepo/issues/events{/number}",
"events_url": "https://api.github.com/repos/SampleOrg/customrepo/events",
"assignees_url": "https://api.github.com/repos/SampleOrg/customrepo/assignees{/user}",
"branches_url": "https://api.github.com/repos/SampleOrg/customrepo/branches{/branch}",
"tags_url": "https://api.github.com/repos/SampleOrg/customrepo/tags",
"blobs_url": "https://api.github.com/repos/SampleOrg/customrepo/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/SampleOrg/customrepo/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/SampleOrg/customrepo/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/SampleOrg/customrepo/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/SampleOrg/customrepo/statuses/{sha}",
"languages_url": "https://api.github.com/repos/SampleOrg/customrepo/languages",
"stargazers_url": "https://api.github.com/repos/SampleOrg/customrepo/stargazers",
"contributors_url": "https://api.github.com/repos/SampleOrg/customrepo/contributors",
"subscribers_url": "https://api.github.com/repos/SampleOrg/customrepo/subscribers",
"subscription_url": "https://api.github.com/repos/SampleOrg/customrepo/subscription",
"commits_url": "https://api.github.com/repos/SampleOrg/customrepo/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/SampleOrg/customrepo/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/SampleOrg/customrepo/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/SampleOrg/customrepo/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/SampleOrg/customrepo/contents/{+path}",
"compare_url": "https://api.github.com/repos/SampleOrg/customrepo/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/SampleOrg/customrepo/merges",
"archive_url": "https://api.github.com/repos/SampleOrg/customrepo/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/SampleOrg/customrepo/downloads",
"issues_url": "https://api.github.com/repos/SampleOrg/customrepo/issues{/number}",
"pulls_url": "https://api.github.com/repos/SampleOrg/customrepo/pulls{/number}",
"milestones_url": "https://api.github.com/repos/SampleOrg/customrepo/milestones{/number}",
"notifications_url": "https://api.github.com/repos/SampleOrg/customrepo/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/SampleOrg/customrepo/labels{/name}",
"releases_url": "https://api.github.com/repos/SampleOrg/customrepo/releases{/id}",
"deployments_url": "https://api.github.com/repos/SampleOrg/customrepo/deployments",
"created_at": "2015-09-07T15:15:41Z",
"updated_at": "2016-01-18T18:35:00Z",
"pushed_at": "2017-08-21T18:23:26Z",
"git_url": "git://github.com/SampleOrg/customrepo.git",
"ssh_url": "git@github.com:SampleOrg/customrepo.git",
"clone_url": "https://github.com/SampleOrg/customrepo.git",
"svn_url": "https://github.com/SampleOrg/customrepo",
"homepage": null,
"size": 4682,
"stargazers_count": 0,
"watchers_count": 0,
"language": "PHP",
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": false,
"forks_count": 0,
"mirror_url": null,
"archived": false,
"open_issues_count": 0,
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "master",
"permissions": {
"admin": false,
"push": true,
"pull": true
}
},
...
मैं एक शेल स्क्रिप्ट में ऐसा कैसे कर सकता हूं जिसमें शायद कोई सरणी या for
लूप हो?
मैंने कोशिश की है कि कोड का निम्नलिखित टुकड़ा है जो पाठ फ़ाइल लाइन को लाइन से पढ़ता है और रिपॉजिटरी को क्लोन करता है, लेकिन इस टेक्स्ट फ़ाइल को बनाने के लिए मुझे clone_url
परम-मान के लिए फ़िल्टर करने से पहले कुछ प्रसंस्करण करने की आवश्यकता है , लेकिन मैं इस हिस्से को छोड़ना चाहता हूं यदि संभव हो तो पूरी तरह से।
while read p; do
#echo $p
git clone $p
done < Orgname_Repos.txt