Beispiel #1
0
    def test_import_commit_sequence(self):
        CommitSequence.objects.all().delete()
        make_commit_sequence(EXAMPLE_GIT_SHOW_OUTPUT)

        self.assertEqual(CommitSequence.objects.count(), 1)
        self.assertEqual(Commit.objects.count(), 3)

        commits = Commit.objects.all()[:]

        self.assertEquals(commits[0].sha1,
                          'f60d7b4858faa696c0581f47ccc81736f9df3ded')
        diffs = commits[0].diffs.all()[:]
        self.assertEquals(len(diffs), 1)
        self.assertEquals(diffs[0].filename, 'a.py')

        self.assertEquals(commits[1].sha1,
                          '242ce960af361fd307ca2fe61bc0a71c29c28394')
        diffs = commits[1].diffs.all()[:]
        self.assertEquals(len(diffs), 2)
        self.assertEquals(diffs[0].filename, 'a.py')
        self.assertEquals(diffs[1].filename, 'b.py')

        self.assertEquals(commits[2].sha1,
                          'c28e535f1024e3b22ec05574aa2287aa5338e3dc')
        diffs = commits[2].diffs.all()[:]
        self.assertEquals(len(diffs), 2)
        self.assertEquals(diffs[0].filename, 'a.py')
        self.assertEquals(diffs[1].filename, 'b.py')
Beispiel #2
0
    def test_import_commit_sequence(self):
        CommitSequence.objects.all().delete()
        make_commit_sequence(EXAMPLE_GIT_SHOW_OUTPUT)

        self.assertEqual(CommitSequence.objects.count(), 1)
        self.assertEqual(Commit.objects.count(), 3)

        commits = Commit.objects.all()[:]

        self.assertEquals(commits[0].sha1, 'f60d7b4858faa696c0581f47ccc81736f9df3ded')
        diffs = commits[0].diffs.all()[:]
        self.assertEquals(len(diffs), 2)
        self.assertEquals(diffs[0].filename, 'a.py')
        self.assertEquals(diffs[1].filename, 'test.file')

        self.assertEquals(commits[1].sha1, '242ce960af361fd307ca2fe61bc0a71c29c28394')
        diffs = commits[1].diffs.all()[:]
        self.assertEquals(len(diffs), 2)
        self.assertEquals(diffs[0].filename, 'a.py')
        self.assertEquals(diffs[1].filename, 'b.py')

        self.assertEquals(commits[2].sha1, 'c28e535f1024e3b22ec05574aa2287aa5338e3dc')
        diffs = commits[2].diffs.all()[:]
        self.assertEquals(len(diffs), 2)
        self.assertEquals(diffs[0].filename, 'a.py')
        self.assertEquals(diffs[1].filename, 'b.py')
Beispiel #3
0
def submit_diff_api(request):
    """ Вьюха для API публикации диффов """
    title = request.POST.get('title')
    diff = request.POST.get('diff')
    login = request.POST.get('login')
    password = request.POST.get('password')
    client_version = request.POST.get('client_version')
    if client_version != settings.CLIENT_VERSION:
        return HttpResponseBadRequest(
            'Version of your client ({0}) is outdated. '
            'Current version is {1}. '
            'Redownload to-review.py. \n\n'
            '    wget "{2}"'.format(
                client_version,
                settings.CLIENT_VERSION,
                request.build_absolute_uri(reverse('download_to_review'))
            )
        )
    if not all((title, diff, login, password)):
        return HttpResponse('Not all parameters are specified (title, diff, login, password - something was empty)', status=400)

    user = get_object_or_404(User, username=login)
    if not user.check_password(password):
        return HttpResponse('Password is incorrect', status=403)

    diff_lines = diff.split('\n')

    sequence = make_commit_sequence(diff_lines, user=user, title=title)
    url = request.build_absolute_uri(sequence.get_edit_url())
    return HttpResponse(url)
Beispiel #4
0
    def handle(self, *args, **options):
        difftext = sys.stdin.read()
        difftext = difftext.decode('utf-8')
        difflines = difftext.split('\n')

        sequence = make_commit_sequence(difflines, title='(stdin)')
        url = settings.ROOT_URL + sequence.get_edit_url()
        print url
Beispiel #5
0
    def handle(self, *args, **options):
        difftext = sys.stdin.read()
        difftext = difftext.decode("utf-8")
        difflines = difftext.split("\n")

        sequence = make_commit_sequence(difflines, title="(stdin)")
        url = settings.ROOT_URL + sequence.get_edit_url()
        print url