GithubHelp home page GithubHelp logo

Comments (4)

tst2005 avatar tst2005 commented on July 23, 2024 2

you have a typo : s/gitst/gists/

from if_ms_buys_github_imma_out.

tst2005 avatar tst2005 commented on July 23, 2024

For now I only have a workaround : "convert all gists to a repository".
I created a repository and import each gist in one separated branch.

git clone all_my_gist_url gists
git clone one_gist_url one_gist
cd gists
git fetch ../one_gist
git checkout -b one_gist FETCH_HEAD

from if_ms_buys_github_imma_out.

sytranvn avatar sytranvn commented on July 23, 2024
#!/usr/bin/env node

const exec = require('child_process').exec
const https = require('https')

console.log(`Fetching gists data of user ${process.argv[2]}`)

function execute(command) {

    exec(command, (err, stdout, stderr) => {
        process.stdout.write(stdout)
    })
}

function request(path) {
    const options = {
        hostname: 'api.github.com',
        path,
        method: 'GET',
        headers: { 'User-Agent': 'Mozilla/5.0' }
    }
    return new Promise((resolve, reject) => {
        let body = ''
        https.get(options, res => {
            res.on('data', data => body += data)
            res.on('end', () => resolve(body))
        })
    })
}

request(`/users/${process.argv[2]}/gists`)
    .then(data => {
        return JSON.parse(data)
    })
    .then(gists => {
        console.log(gists)
        gists.forEach(gist => {
            const file = Object.keys(gist.files)[0]
            console.log('Found gist ' + file)
            console.log(`Cloning ${gist.git_pull_url} into ${file}...`)

            exec(`git clone ${gist.git_pull_url} ${file}`)
        })
    })
    .then(() => console.log('Waiting for the magic.....'))

I ended up writing a script myself to do the job. But this script just works on public gists only.
Just create clone.js file with script above, then run clone.js your_account. Next step is to auto push those gists to gitlab smh.
BTW, I'm not sure if it works on Windows 😕

from if_ms_buys_github_imma_out.

sytranvn avatar sytranvn commented on July 23, 2024

Thanks mate.
I also found gitlab api documents to create snippets here. https://docs.gitlab.com/ee/api/snippets.html#create-new-snippet
I will try to write step 2 soon.

from if_ms_buys_github_imma_out.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.