4 points
*

Probably this script:

#!/bin/bash

if [ -z "$1" ]
then
        echo "Please provide git repository url as an argument for this script."
        exit 1
fi
regex='(https?|ftp|file)://[-[:alnum:]\+&@#/%?=~_|!:,.;]*[-[:alnum:]\+&@#/%=~_|]'
if [[ $1 =~ $regex ]]
then
basename=$(basename $1)
reponame=${basename%.*}
curl -X 'POST' 'https://localgitea.com/api/v1/repos/migrate?access_token={Access Token Here}' \
  --insecure \
  -H "accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{  "clone_addr": "'"$1"'",  "issues": false,  "labels": false,  "lfs": false,  "mirror": true,  "mirror_interval": "96h0m0s",  "private": false, "repo_name": "'"$reponame"'", "pull_requests": true,  "releases": true, "repo_owner": "githubpublic",  "service": "git",  "wiki": true}'
else
        echo "Invalid URL"
        exit 1
fi

You can adjust it as needed and as for why I have --insecure flag, I have a direct network cable between my PC to the server, so encryption or HTTPS is not needed here. This is probably my favorite command, because I would write above as .sra.sh in home directory and then alias the .bashrc to make a sra command by adding alias sra=/home/{your user account}/.sra.sh in .bashrc and from there, anytime I have an interesting repository that I want to archive, I simply run sra {git url} and that’s it. It also specify the mirror interval manually for 4 days interval rather than every 8 hours that would’ve needlessly spam the git server.

This is something I rely on everyday both as developer and system admin, I would maintain a different supply chain and prevent a supply chain attacks by generating my own package feeds/registry automatically from Gitea/Forgejo.

Edited to Add: I noticed this community is Powershell, here the powershell version of above:

param (
    [Parameter(Mandatory=$true)]
    [string]$gitRepoUrl
)

function Test-Url($url) {
    $regex = "(https?|ftp|file)://[-[:alnum:]\+&@#/%?=~_|!:,.;]*[-[:alnum:]\+&@#/%=~_|]"
    return $url -match $regex
}


$basename = Split-Path $gitRepoUrl -Leaf
$reponame = [System.IO.Path]::GetFileNameWithoutExtension($basename)

$headers = @{
    'accept' = 'application/json'
    'Content-Type' = 'application/json'
}

$body = @{
    'clone_addr' = $gitRepoUrl
    'issues' = $false
    'labels' = $false
    'lfs' = $false
    'mirror' = $true
    'mirror_interval' = '96h0m0s'
    'private' = $false
    'repo_name' = $reponame
    'pull_requests' = $true
    'releases' = $true
    'repo_owner' = 'githubpublic'
    'service' = 'git'
    'wiki' = $true
} | ConvertTo-Json

Invoke-RestMethod -Uri 'https://localgitea.com/api/v1/repos/migrate?access_token={Access Token Here}' -Method POST -Headers $headers -Body $body -SkipCertificateCheck

permalink
report
reply
2 points

Edited to Add: I noticed this community is Powershell, here the powershell version of above:

Nice! You are a person of many talents

permalink
report
parent
reply
3 points

The Cisco and Fortinet Ansible galaxy collections.

Documentation is top notch too.

permalink
report
reply
4 points

Documentation is top notch too.

Nothing will make me love a solution more than it being well documented. Sounds simple, but saves so much time.

permalink
report
parent
reply
2 points

I’ve been a huge winget fanboy for a while now. I liked chocolatey prior to that, but it works so well with the os - which makes sense cuz it’s from Microsoft.

permalink
report
reply
2 points

I love WinGet but I just wish there was support for Windows Server, without having to do a bunch of hacks

permalink
report
parent
reply
2 points

That’s a very good point. Must my dev work doesn’t involve a Windows server except for interacting with AD, I forget winget has that limitation. Hopefully they add that feature soon!

permalink
report
parent
reply

Powershell

!powershell@programming.dev

Create post

PowerShell (POSH) is a a task automation command-line shell and scripting language created by Microsoft. It became part of the FOSS community in 2016 and is now available across Windows, Linux, and macOS

Resources:


Rules:

  • Be civil (aka don’t be a jerk). Remember there are people from all walks of life, all with different levels of expertise. You can disagree with someone, but please be civil when doing so.
  • Adhere to the Lemmy Code of Conduct
  • Follow all programming.dev rules
  • Posts must relate to PowerShell or the PowerShell ecosystem.
  • Use code blocks to make things easier to read.
  • Memes and humorous posts are allowed but try not over do it. And keep them relevant to PowerShell
  • No discussion about piracy or hacking.
  • If someone provides an answer that solves your problem, please reply, so others know what the solution was. And so the person who suggested it gets that oh so sweet shot of dopamine.
  • If you find a solution to your problem by other means, please take your time to write down the steps you used to solve your problem in the original post. You can potentially help others having the same problem!

Self-promotion rules:

  • Self-promotion content must be marked as [OC]
  • Do not SPAM. Content must be PowerShell related.
  • Only 10% of your contributions can be self-promotion. In other words, 90% of your contribution must not be self-promotion.
  • Personal blogs are not considered self-promotion, at this time, as long as they are free to access and relevant. Please do not abuse this.

Community stats

  • 24

    Monthly active users

  • 81

    Posts

  • 98

    Comments