Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- use Data::Dumper;
- use File::Basename;
- my $numArgs = $#ARGV + 1;
- if($numArgs < 2) {
- die "Usage: $0 [Bit Bucket Project e.g. FW, BDPE] [repo name] [-d dry run (optional)]";
- }
- my $bitbucketProject = lc $ARGV[0];
- my $repoName = $ARGV[1];
- my $dryRun = $ARGV[2];
- my %moduleHash;
- my $bitBucketServer = "localhost";
- my $user = "admin";
- my $password = "bitbucket";
- print "Bit Bucket Project: $bitbucketProjectn";
- print "Repository name: $repoNamen";
- sub importRepo {
- my $command = sprintf("curl -u %s:%s -X POST -H "Content-Type: application/json" -d '{
- "name": "%s",
- "scmId": "git",
- "forkable": true
- }' http://%s:7990/rest/api/1.0/projects/%s/repos", $user, $password, $repoName, $bitBucketServer, $bitbucketProject);
- if ($dryRun) {
- print "$commandn";
- } else {
- print "Doing importn";
- system $command;
- }
- my $bitbucketUrl = sprintf("ssh://git@%s:7999/%s/%s.git", $bitBucketServer, lc $bitbucketProject, $repoName);
- my $gitCommand = sprintf("cd %s; pwd; git repack -a -d -f; git push %s --mirror", $repoName, $bitbucketUrl);
- if ($dryRun) {
- print "$gitCommandn";
- } else {
- print "Running gitn";
- system $gitCommand;
- }
- }
- importRepo();
- #!/bin/bash
- BITBUCKETPROJECT=$1
- if [ $# -ne 2 ]; then
- echo "Usage: $0 [Bit Bucket Project] [Path to repos]"
- exit 1;
- fi
- echo "Bit bucket project: $BITBUCKETPROJECT"
- for f in *; do
- if [[ -d $f ]]; then
- echo $f
- ./importRepository.pl $BITBUCKETPROJECT $f
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement