Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 107 lines (96 sloc) 3.433 kB
c5f98b5 @holdenk Initial collection of shaaady perl scripts to do the spelling correct…
authored
1 #!/usr/bin/perl -s
2 $| = 1;
3 use LWP::UserAgent;
4 use Net::Twitter;
3b92e73 @holdenk Migrate towards using Pithub & support for grabbing from the root repo.
authored
5 use Pithub;
6 use Data::Dumper;
7
4a37583 a few cleanup fixes
Shmuel Fomberg authored
8 use wordlist qw{fix_text check_common};
3b92e73 @holdenk Migrate towards using Pithub & support for grabbing from the root repo.
authored
9 use strict;
c5f98b5 @holdenk Initial collection of shaaady perl scripts to do the spelling correct…
authored
10
3b92e73 @holdenk Migrate towards using Pithub & support for grabbing from the root repo.
authored
11 my $token ="";
12 my $user = "holdensmagicalunicorn";
13
14 my $p = Pithub->new;
15
16 my $consumer_key = "";
17 my $consumer_secret = "";
c5f98b5 @holdenk Initial collection of shaaady perl scripts to do the spelling correct…
authored
18
19
3b92e73 @holdenk Migrate towards using Pithub & support for grabbing from the root repo.
authored
20 my $c = 0;
21 print "using ck $consumer_key / secret $consumer_secret\n";
c5f98b5 @holdenk Initial collection of shaaady perl scripts to do the spelling correct…
authored
22 my $nt = Net::Twitter->new(
23 traits => [qw/OAuth API::REST/],
24 consumer_key => $consumer_key,
25 consumer_secret => $consumer_secret,
26 );
27 $nt->access_token();
28 $nt->access_token_secret();
29
30 my $ua = new LWP::UserAgent;
31 print "Hello!\n";
32 print "Connecting to github!\n";
33 print "Reading input\n";
34 while (my $l = <>) {
3b92e73 @holdenk Migrate towards using Pithub & support for grabbing from the root repo.
authored
35 if ($l =~ /github\.com\/(.*?)\s*$/) {
36 print "Checking $1\n";
37 my $url = "https://www.github.com/".$1;
38 $url =~ s/raw\/.*?\//raw\/master\//;
39 handle_url($url);
40 } else {
41 print "fuck $l\n";
c5f98b5 @holdenk Initial collection of shaaady perl scripts to do the spelling correct…
authored
42 }
43 }
44
45 sub handle_url {
46 my $url = shift @_;
3b92e73 @holdenk Migrate towards using Pithub & support for grabbing from the root repo.
authored
47 print "looking at $url\n";
48 if ($url =~ /http.*\/(.*?)\/(.*?)\/(raw\/|)(master|development)\/(.*)/) {
49 my $ruser = $1;
50 my $repo = $2;
51 my $file = $4;
52 print "u:".$ruser."\n";
53 print "r:".$repo."\n";
54 print "f:".$file."\n";
55 my $result = $p->repos->get( user => $ruser , repo => $repo);
56 my $traverse = 0;
57 #Do we need to go up a level?
58 while ($traverse < 10 && $result->content->{source}) {
59 my $above = $result->content->{source}->{url};
60 print "Yup, source exists was pulled from $above\n";
61 if ($above =~ /repos\/(.*?)\/(.*)$/) {
62 $ruser = $1;
63 $repo = $2;
64 }
65 $result = $p->repos->get( user => $ruser , repo => $repo);
66 $traverse++;
67 }
68 #Ok dokey lets try and fork this business
69 my $f = Pithub::Repos::Forks->new(user => $user ,token => $token);
70 my $result = $f->create( user => $ruser, repo => $repo);
71 print "got back ".Dumper($result->content)."yay?";
72 my $clone_url = $result->content->{ssh_url};
73 my $upstream_url = $result->content->{parent}->{ssh_url};
74 my $master_branch = $result->content->{parent}->{master_branch};
75 #Oh hey lets merge the latest business to eh (just in case we have an old fork)
76 `rm -rf foo && mkdir -p foo && cd foo && git clone "$clone_url" && cd * && git remote add upstream "$upstream_url" && git fetch upstream && git merge upstream/$master_branch && git push`;
77 #Get the files
78 my @all_files;
79 open (my $files,"find ./foo/|");
80 while (my $file = <$files>) {
81 chomp ($file);
82 push @all_files, $file;
83 }
84 close ($files);
85 #Now we iterate through each of the processors so the git commit messages are grouped logically
86
87 }
88 }
89 sub fix_readme {
90 my $file = shift @_;
91 if ($file =~ /\/README(\.txt|\.rtf|\.md|\.m\w+)$/) {
92 print "Checking $file for readme changes";
93 open (my $in, "<", "$file") or die "Unable to open $file in $repo";
94 my $t = do { local $/ = <$in> };
95 close($in);
96 #Is there a spelling mistake?
97 if (check_common($t)) {
98 open ($out, ">", "$file") or die "Unable to open $file in $repo";
99 print $out fix_text($t);
100 close ($out);
101 }
102 } elsif ($file =~ /\/README\.pod$/) {
103 #Handle pod l8r
c5f98b5 @holdenk Initial collection of shaaady perl scripts to do the spelling correct…
authored
104 }
105 }
3b92e73 @holdenk Migrate towards using Pithub & support for grabbing from the root repo.
authored
106
Something went wrong with that request. Please try again.