Skip to content

Instantly share code, notes, and snippets.

@mishin
Created August 22, 2016 13:15
Show Gist options
  • Select an option

  • Save mishin/22adb441f98a9fec42c501e1087fefbd to your computer and use it in GitHub Desktop.

Select an option

Save mishin/22adb441f98a9fec42c501e1087fefbd to your computer and use it in GitHub Desktop.
If we want to convert svn repository to git we do next:
````
git svn clone --authors-file=authors.txt --no-metadata http://vcs/svn/ESB/ESB.Report/trunk ESB.Report
````
after that we got the following link:
````
git@server.main.mycompany.ru:ESB/esb-creport.git
````
than we create repository in git (gitlab):
````
use strict;
use warnings;
use 5.010;
my @projects = qw(ESB.Report ESB.Report2);
foreach my $project (@projects) {
say qq{curl --header "PRIVATE-TOKEN: \${token}" -X POST "http://server.main.mycompany.ru/api/v3/projects?name=${project}&namespace_id=24"};
}
````
cat make_repo.sh
````
#!/bin/bash
token=Wsfdasf45546
curl --header "PRIVATE-TOKEN: ${token}" -X POST "http://server.main.mycompany.ru/api/v3/projects?name=ESB.Report&namespace_id=24"
so upcase making lowercase and dot (.) replace with dash (-)
after that we got
````
git@server.main.mycompany.ru:ESB/esb-creport.git
````
to fix it we can create it correct
````
curl --header "PRIVATE-TOKEN: %token%" -X POST "http://server.main.mycompany.ru/api/v3/projects?name=ESB.Report&namespace_id=24&path=ESB.Report"
````
or fix with script
````perl
use v5.10;
use GitLab::API::v3;
my $v3_api_url = 'http://my_server/api/v3/';
my $token = 'rrqwerqwrtasvfdasva';
my $api = GitLab::API::v3->new(
url => $v3_api_url,
token => $token,
);
my $all_projects = $api->paginator( 'projects' )->all();
for my $proj (@{$all_projects}) {
my %params = (path => $proj->{name});
say "Change path for project id: $proj->{id} from $proj->{path} to $proj->{name}";
change_project($proj->{id}, \%params);
}
sub change_project {
my ($id, $params) = @_;
$api->edit_project(
$id,
$params,
);
}
````
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment