Last active
December 4, 2024 08:53
-
-
Save paazmaya/97fbd2b487951bb6cbccc7ecdcc4dc13 to your computer and use it in GitHub Desktop.
Get git clone commands from Gitlab repositories in your own profile page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copy these to the browser console. Using let instead of const to allow reassinging when its sometimes needed. | |
// Get a list of GitLab project URLs from a page | |
let list = document.querySelectorAll('.project-details h2 a'); | |
let urls = Array.from(list).map(item => item.getAttribute('href')); | |
// Remove the leading / from the URLs and combine with SSH git URL | |
let ssh_git_urls = urls.map(item => item.replace(/^\//, '')).map(item => `[email protected]:${item}.git`); | |
// Add clone command to the URLs | |
ssh_git_urls.forEach(item => console.log(`git clone ${item}`)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment