Ubuntu Pastebin

Paste from a at Fri, 20 Mar 2015 11:53:59 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
require 'fileutils'
require 'git'
require 'json'
require 'logger'
require 'logger/colors'
require 'tmpdir'

logger = Logger.new(STDOUT)
logger.level = Logger::INFO

repos = %x[ssh git.debian.org ls /git/pkg-kde/plasma].chop!.gsub!('.git', '').split(' ')
logger.debug "repos: #{repos}"

without_unstable_branch = []

Dir.mktmpdir('stabilizer') do |tmpdir|
  Dir.chdir(tmpdir)
  repos.each do |repo|
    logger.progname = repo
    logger.info '----------------------------------'

    git = nil
    if !File.exist?(repo)
      git = Git.clone("debian:plasma/#{repo}", repo)
    else
      git = Git.open(repo)
    end

    git.clean(force: true, d: true)
    git.reset('origin', hard: true)
    git.fetch

    begin
      git.checkout('kubuntu_stable')
    rescue Git::GitExecuteError
      without_unstable_branch << repo
      next
    end
    git.pull('origin', 'kubuntu_stable')

    branches = git.branches

    has_remote = false
    branches.remote.each do |b|
      if b.name == 'kubuntu_vivid_archive'
        logger.info 'has archive remote'
        has_remote = true
        break
      end
    end

    has_local = false
    branches.local.each do |b|
      if b.name == 'kubuntu_vivid_archive'
        logger.info 'has archive local'
        has_local = true
        break
      end
    end

    if has_remote || has_local
      git.checkout('kubuntu_vivid_archive')
      git.merge('kubuntu_stable')
    else
      git.checkout('kubuntu_vivid_archive', new_branch: true)
    end

    # Setup upstream_scm.json
    #
    # scm_changed = false
    # if (scm[:type].nil? || scm[:type] == 'git') && (scm[:branch] != branch)
    #   logger.info "twiddling scm branch for git"
    #   scm[:branch] = branch
    #   scm_changed = true
    # elsif (scm[:type] && scm[:type] == 'svn') && scm[:url] && !scm[:url].include?(branch.downcase)
    #   logger.info "twiddling scm branch for svn"
    #   scm[:url].gsub!('trunk/KDE', "branches/#{branch.downcase}")
    #   scm_changed = true
    # end
    # if scm_changed
    #   logger.debug scm
    #   File.write(scm_path, JSON.generate(scm))
    #   git.add(scm_path)
    #   git.commit("Set upstream SCM branch to #{branch}")
    # end
  end

  repos.each do |repo|
    next if without_unstable_branch.include?(repo)
    git = Git.open(repo)
    git.push('origin', 'kubuntu_vivid_archive')
  end
end

without_unstable_branch.each do |repo|
  logger.progname = ''
  logger.warn "#{repo} has no kubuntu_stable branch apparently!!"
end
Download as text